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

New Row

When datagrid add a new row, what is the event that is launched? I should add programically data to some cells on a new row after it's created.

1 Reply

AD Administrator Syncfusion Team March 14, 2003 05:09 AM

Hi. I have had the same problem when the new row needs a foreign key value and I have to set it programically. I use to add a handler like this Private Sub InitializeClassRoomBookingsGrid() AddHandler dsClassRoomBookings.tblClassRoomBookings.RowChanged, AddressOf HandleClassRoomBookingTableRowChanged ... ... End Sub And write the function it calls (HandleClassRoomBookingTableRowChanged) ' Purpose: Solves the problem with foreign keys when adding a new row to the ' dsClassRoomBookings.tblClassRoomBookings datatable. ' Input: sender = dsClassRoomBookings.tblClassRoomBookings datatable. ' e = DataRowChangeEventArgs ' Output: Setting the fields CRB_CRID to the same values as in the ClassRoomsListBox Sub HandleClassRoomBookingTableRowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) If e.Row("CRB_CRID") Is DBNull.Value Then e.Row("CRB_CRID") = dsClassRooms.ClassRooms.Rows(ClassRoomsListBox.SelectedIndex)("CR_ID") End If End Sub One problem you can bump into is that the Foreign key field doesnt allow Null values. I solved it by using a strongly typed dataset and then you can change property for the field to allow Null values. If this is your case and you dont understand the last part then reply on the message.

Loader.
Live Chat Icon For mobile
Up arrow icon