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.
Unfortunately, activation email could not send to your email. Please try again.

New Row

Thread ID:

Created:

Updated:

Platform:

Replies:

3312 Mar 12,2003 05:33 AM Mar 14,2003 05:09 AM Windows Forms 1
loading
Tags: FAQ
Administrator [Syncfusion]
Asked On March 12, 2003 05:33 AM

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.

Administrator [Syncfusion]
Replied On 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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;