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
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.
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.
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(); |
} |
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.