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

Adding a key to new row in datagrid

I have a data grid bound to a typed dataset with a primary key. How do I set a value for the key after adding a new row.

1 Reply

AD Administrator Syncfusion Team February 6, 2006 04:13 AM UTC

Hi Kingsley, You can use the RowEditing event for selecting the Primary key. In the event, check for the last row index and add the primary key respectively. Here is the code snippet. private void gridDataBoundGrid1_RowEditing(object sender, Syncfusion.Windows.Forms.Grid.GridRowEventArgs e) { if(this.gridDataBoundGrid1.Model.RowCount == e.RowIndex) { this.gridDataBoundGrid1[e.RowIndex,1].CellValue = e.RowIndex; } } Refer this sample for details. Let us know if you need further assistance, Regards, Madhan.

Loader.
Live Chat Icon For mobile
Up arrow icon