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

Not seeing updates in DataViews

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"))); ds.Tables.Add(dt); DataView dv = new DataView(dt); DataView dv2 = new DataView(dt); dv2.ListChanged += new ListChangedEventHandler(dv_ListChanged); DataRowView drv = dv.AddNew(); drv.BeginEdit(); drv["Name"] = "Foo"; drv.EndEdit(); 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. Any ideas? [I''d expect to see ListChanged events whenever I add a row in the GDBG while using the program...]

7 Replies

AD Administrator Syncfusion Team April 22, 2005 11:18 PM UTC

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);


AD Administrator Syncfusion Team April 24, 2005 03:47 AM UTC

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. Thanks, Dan


AD Administrator Syncfusion Team April 24, 2005 08:52 AM UTC

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 3.0.1.0). 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;


AD Administrator Syncfusion Team April 24, 2005 09:04 AM UTC

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...]


AD Administrator Syncfusion Team April 24, 2005 12:06 PM UTC

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. http://www.syncfusion.com/Support/user/uploads/gDBG_DataViews_53b5529b.zip


AD Administrator Syncfusion Team April 24, 2005 10:51 PM UTC

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.. Thank you, Dan


AD Administrator Syncfusion Team April 24, 2005 11:26 PM UTC

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.

Loader.
Live Chat Icon For mobile
Up arrow icon