I have a WinGrid pulling from a datasource... specifically, it's pulling data from an MS-SQL database. The datasource has a single table. What I want to do is pull the data in, then allow the user to do some sort of automated processing. In this case, the program will scan through and consolidate indivdual values into ranges, the purpose being to decrease the number of rows by collapsing individual values into ranges of values. So it's necessary to delete the rows I don't want and to insert the new rows with the comprehensive ranges.
I wrote the code to process the data, no problem. It builds a list of what needs to be deleted and what needs to be added. Then it deletes the rows in question. Last but not least, it inserts the new rows. That's when the error occurs: "Row insertion not supported by this data source"
Let me be clear. At this point in the process I have complete lists of what needs to be deleted and inserted. The data deletes properly. Testing up to that point shows that it works fine. The grid/datasource displays the rows in the table, then shows the table after the specified rows have been deleted, all correctly. But when I try to programatically insert the new data, the error occurs. I have everywhere I can find set to allow adds. I made sure none of the columns are read-only.
This is the code that performs the actual add to the row.
UltraGridRow row = grdLCDDiags.DisplayLayout.Bands[0].AddNew();
row.Cells["BeginCode"].Value = ListOfActions[ndx].Diags.DiagBegin;
row.Cells["EndCode"].Value = ListOfActions[ndx].Diags.DiagEnd;
row.Update();
I am working with C# in .NET 2008, and I am using version 8.2.20082.2011 of the WinGrid (runtime version v2.0.50727). Thanks in advance for any advice.
What is the grid bound to in this case? In order for the grid to support the addition of rows, the underlying data source needs to implement IBindingList. This is because the grid uses the .NET BindingManager to perform these operations (specifically calling AddNew() on the IBindingList implementation), so this is likely the cause of the error.
-Matt
The grid is bound to a datasource, in this case a table in a dataset. The datasource is "policyGroupDiagsBindingSource", which is of type "Windows.System.Forms.BindingSource".
As far as I can tell, it should work. I mean, it loads fine from the database (MS-SQL), and it let's me delete the rows I don't need. If it does all that, it should also let me add a new row.
I agree with you, it sonuds like it should be working if it's with a standard DataTable (even through a BindingSource). Unfortunately, I don't really have any ideas why you would be getting this exception when using a DataTable, so you should probably submit a small sample to Developer Support.