I''m sure I''m doing something dumb, but, I have the following:
private void InitDataset()
DataSet ds = new DataSet("ds");
DataTable dt = new DataTable("Test");
dt.Columns.Add(new DataColumn("Name", System.Type.GetType("System.String")));
dt.Columns.Add(new DataColumn("Date", System.Type.GetType("System.DateTime")));
DataView dv = new DataView(dt);
DataView dv2 = new DataView(dt);
dv2.ListChanged += new ListChangedEventHandler(dv_ListChanged);
DataRowView drv = dv.AddNew();
drv["Name"] = "Foo";
gridDataBoundGrid1.DataSource = dv;
I see my dv_ListChanged get called when I add the row "Foo". But, if I add rows to the GDBG when using the program, I never see dv_ListChanged get called. It looks like the binding is never updating the underyling DataTable.
[I''d expect to see ListChanged events whenever I add a row in the GDBG while using the program...]
ADAdministrator Syncfusion Team April 22, 2005 06:18 PM
The grid''s DataSource is dv.
>>gridDataBoundGrid1.DataSource = dv;
But you are subscribing the ListChanged event of dv2 which is different than dv.
>>DataView dv2 = new DataView(dt);
>>dv2.ListChanged += new ListChangedEventHandler(dv_ListChanged);
Try subscribing to dv.ListChanged to see if that makes things get hit when you add data in teh grid.
dv.ListChanged += new ListChangedEventHandler(dv_ListChanged);
ADAdministrator Syncfusion Team April 23, 2005 10:47 PM
Thats for getting back. The point is that they''re different dataviews on the same underlying table.
(This was a simplified example, but in real life, dv2 would have a different RowFilter).
As I understand it, I should be able to add cells in the grid (which is bound to dv) and the underyling DataTable will be updated which will in turn cause events to be fired on dv2.
ADAdministrator Syncfusion Team April 24, 2005 03:52 AM
The grid does not pass the changes back to the underlying currencymanager until you leave the row in the grid. So, you should see the event on the second DataView when you click off newly added row. (I see this here using 188.8.131.52).
If you want to commit the changes to the currencymanager as you leave the cell (as opposed to leaving the row), you can set these properties on the grid''s Binder object.
this.gridDataBoundGrid1.DataSource = dv;
this.gridDataBoundGrid1.Binder.DirectSaveCellInfo = true;
this.gridDataBoundGrid1.Binder.OptimizeListChangedEvent = false;
ADAdministrator Syncfusion Team April 24, 2005 04:04 AM
Hmm. I added those lines, but I still don''t ever see my event fired from dv2. Moreover, looking at it, it doesn''t look like the changes in the grid to dv are being propagated back to the DataTable.
[I wasn''t seeing them beofre when I left the row...]
ADAdministrator Syncfusion Team April 24, 2005 07:06 AM
Here is the sample I tried using 3010. I also dropped a Windows Forms Datagrid onto the form and bound it directly to the DataTable to see when the changes in the GridDataBoundGrid get pushed back to the DataSource. Do you see the problem in this sample. I have it set so the changes get committed when you click off the cell.
ADAdministrator Syncfusion Team April 24, 2005 05:51 PM
Just tried your example. It seems to work just fine. So far, I can''t find any salient difference between that and my code, but I''ll keep looking..
ADAdministrator Syncfusion Team April 24, 2005 06:26 PM
That example helped; I''m not quite sure what the difference is, but I just copied your version and pasted in my code and it works.
Must have been some difference I missed. Thanks.