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

UpdatingRecord Event

I am implementing a custom collection that implements both IBindingList and IListSource and inherits from CollectionBase. I have no problem binding my collection to the grid. My question: 1) how can I save changes made by the user to the collection 2) is there an (UpdatingRecord) like event that occurs before the changes made by the user are committed to the datasource (so that data can be validated and the event canceled if necessary) 3) is there an (AddingRecord) like event that occurs before adding a new record to the datasource (so that a new item can be created in the collection and data can be validated and canceled if necessary) OMAR P.S: when should we expect to see V2.0 of the grid!!

1 Reply

AD Administrator Syncfusion Team September 9, 2003 05:28 PM

1) You can have the objects in your datasource implement IEditableObject interface. You can take a look at the Syncfusion\Essential Suite\Grid\Samples\DataBound\Hierarchical\Customers that uses a IBindingList datasource. 2) From the GridDataBoundGrid, you can use the RowLeave event which can be cancelled and happens as you leave a row. You can check grid.Binder.IsAnyDirtyField to see if any changes needs saving. 3) There is no AddNewRow event, but you can do this in the RowEnter event checking whether you are on the last row. Here is some code that adds a new row to a DataTable in RowEnter.
Private Sub gridDataBoundGrid1_RowEnter(sender As Object, e As GridRowEventArgs) Handles GridDataBoundGrid1.RowEnter

   If Me.gridDataBoundGrid1.Model.RowCount = e.RowIndex Then
      Dim dt As DataTable = CType(Me.gridDataBoundGrid1.DataSource, DataTable)
      Dim dr As DataRow = dt.NewRow()
      ’populate your new row however you want
      dr(0) = "col0"
      dr(1) = "col1"
      dt.Rows.Add(dr)
   End If
End Sub ’gridDataBoundGrid1_RowEnter
The 2.0 beta will start in a week or so.

Loader.
Live Chat Icon For mobile
Up arrow icon