We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

DataGrid/DataSet DataRow index problem when inserting rows

I have been playing with a great sample from the FAQ 5.6 deriving a custom column style to nest a comboBox in a DataGrid column. Everything works fine until I insert a new row into the dataset instead of adding the row (using the Rows.InsertAt() method). TC_DataSet.Tables["TC_Table"].Rows.InsertAt(newRow1,TC_Row); TC_DataSet.Tables["TC_Table"].AcceptChanges(); The record shows up in the DataGrid but when you start clicking on other rows(or using cursor keys) to move to other rows, C# gives an invalid index message: "System.IndexOutOfRangeException" The Grid seems to think there is one more row than there should be - it doesn't seem to be sync'ed up with the dataset. I have seen some other similar complaints on the net but no indication of what the issue might be. Any insight would be appreciated.

6 Replies

AD Administrator Syncfusion Team October 3, 2002 11:19 AM UTC

That sample was modified last week to handle some last row problems, so you might check to see if you have the latest version. You might also try calling refresh on the datagrid's currency manager. CurrencyManager cm = (CurrencyManager) this.BindingContext[this.myDataGrid.DataSource, this.myDataGrid.DataMember]; cm.Refresh(); to see if that gets things back in sync.


PE PeteB October 3, 2002 03:37 PM UTC

I gave it a shot but it is still giving the same exception. It seems to be in the System.Data.DataView.OnListChanged method but I can't be sure - just can't nail it down. I have attached FAQ example 5.6 and added a button to Insert a row. If you run the sample, click on the button and then start clicking rows in the grid, you will see some interesting results.


AD Administrator Syncfusion Team October 4, 2002 08:55 AM UTC

We modified that sample a few days ago with a suggestion by Gerald Walsh that I think takes care of the problem you are having. We removed some code at the top of the Edit method and the entire ComboMadeCurrent method. We added a handler for SelectionChangeCommitted. You might try getting the sample code again and trying your add button with the new code.


PE PeteB October 4, 2002 10:42 AM UTC

The updated code does not seem to be there - the ComboMadeCurrent method is still there. I checked the samples in 5.6, 5.40 & 5.54. Would you have a link to it? Thanks!


AD Administrator Syncfusion Team October 4, 2002 03:20 PM UTC

Oops. Our overnight upload from our local server has been broken for a couple of days, so the automatic upload has not been happening. I did a manual upload so you should be able to get the new files now. Sorry.


PE PeteB October 7, 2002 03:00 PM UTC

Well...I have tried quite a few things including; - the new sample code - refreshing currency manager but it still will not work correctly. If you have any further suggestions, I would appreciate it. If you could take a quick look...I have attached the new 5.6 example with a button to insert a row into your grid: Run the example, click the button to insert a row and then change the city in the combobox for each row, particularly the rows after the inserted row. Duplicate rows appear and values in the city column can get mixed up. Eventually an exception will appear. I can not explain why.

Loader.
Live Chat Icon For mobile
Up arrow icon