This is a migrated thread and some comments may be shown as answers.

Remove Row Error

5 Answers 86 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joe Bohen
Top achievements
Rank 1
Joe Bohen asked on 07 Oct 2009, 01:39 PM

Hi
I have an unbound radgridview and I am deleteing the row with an ID value of 0 the code runs but the row is still visible in the grid and when the radgridview is selected I get an error:

 

System.Data.RowNotInTableException was unhandled

  Message="This row has been removed from a table and does not have any data.  BeginEdit() will allow creation of new data in this row."

  Source="System.Data"

 

 

For x As Integer = 0 To Me. radgridview1.Rows.Count - 1

                    If (Me. radgridview1.Rows(x).Cells("ID").Value) = 0 Then

                        Me.Packagelist.Rows.RemoveAt(x)                       

                        Exit For

                    End If

                Next

How do I remove the row from the grid and avoid the error?
Regards
Joe

5 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 09 Oct 2009, 10:46 AM
Hello Joe Bohen,

The update operation has some errors in this situation. We logged the problem and the fix will be available in our next release. Currently you can call the Update method of MasterGridViewTemplate after you remove a row.

Me.Packagelist.MasterGridViewTemplate.Update(GridUINotifyAction.RowsChanged);

Kind regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jon Rowland
Top achievements
Rank 1
answered on 30 Nov 2009, 12:15 PM
I also have this problem. But my grid has a group by expression. When I call Update on the MasterGridViewTemplate, this causes the last group in my grid to be collapsed. What is the workaround for this?

Regards, Jon

0
Nikolay
Telerik team
answered on 03 Dec 2009, 01:59 PM
Hello Jon Rowland,

You can save the expanded groups and re-expand them after you call the Update method. Please refer to the code snippet below:
Private expandedGroups As HashSet(Of String) = New HashSet(Of String)()
Private Sub radButton1_Click(ByVal sender As Object, ByVal e As EventArgs) 'save logic
    Me.expandedGroups.Clear()
    Dim i As Integer = 0
    Do While i < Me.radGridView1.Groups.Count
        If Me.radGridView1.Groups(i).IsExpanded Then
            expandedGroups.Add(Me.radGridView1.Groups(i).HeaderRow.GetSummary())
        End If
        i += 1
    Loop
End Sub
  
Private Sub radButton2_Click(ByVal sender As Object, ByVal e As EventArgs) 'restore logic
    Me.Packagelist.MasterGridViewTemplate.Update(GridUINotifyAction.RowsChanged)
    Dim i As Integer = 0
    Do While i < Me.radGridView1.Groups.Count
        Dim text As String = Me.radGridView1.Groups(i).HeaderRow.GetSummary()
        If expandedGroups.Contains(text) Then
            Me.radGridView1.Groups(i).Expand()
        End If
        i += 1
    Loop
End Sub

I hope this helps. If you have additional questions, feel free to contact me.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
djsowa
Top achievements
Rank 1
answered on 04 Feb 2010, 04:27 PM

I have the same issue, I try to do some like this:

 public DataView GetByDataViewFilter(string filter)  
        {  
            string sort = "";  
            if (SortByStore)  
                sort = "store_name ASC, document_id DESC";  
            DataView result = new DataView(documents, filter, sort, DataViewRowState.CurrentRows);  
            //documents is type of DataTable
            return result;  
        }  
 
        private void ShowData()  
        {  
            string filter = "";  
            if (FilterByType && FilterTypeId != 0)  
            {  
                filter = "document_type_id = " + FilterTypeId.ToString();  
            }             
            dgvDocuments.DataSource = GetByDataViewFilter(filter);  
            FinishDocumentsView();  
        } 
When I call ShowData after documents rows count is less then before I have System.Data.RowNotInTableException error.

0
Nikolay
Telerik team
answered on 10 Feb 2010, 10:26 AM
Hi djsowa,

The code snippet that you provided is not enough for us to reproduce the issue. Therefore, I would kindly ask you to open a new ticket and send us a sample project which demonstrates the exception. This will allow me to investigate your case and provide you with a workaround if such is available.

Kind regards,
Nikolay
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
GridView
Asked by
Joe Bohen
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Jon Rowland
Top achievements
Rank 1
Nikolay
Telerik team
djsowa
Top achievements
Rank 1
Share this question
or