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

How to Write GridControl Values to a DataTable/Database

We are using the GridControl where we read an Oracle database Table into a DataTable and then populate the gridcontrol. When the user is done making changes and selects the save feature what is most efficient way to write back the entire grid contents to the Database. Bob

1 Reply

AD Administrator Syncfusion Team May 27, 2005 06:37 PM

I assume you have used a DataAdapter of some type to load the data into a DataSet/DataTable, and then have moved the data from the DataTable into the GridControl. If you want to, you can handle the grid.SaveCellInfo event. In the handler, assuming dataTable1 is the DataTable, you can use code similar to the code below to move the changes back into the DataTable as the user makes the changes. Then when you want to move these changes back into the database, you can call DataAdapter.Update. You would not have to move the changes from the grid to the Datatable as that would have been done as the user typed and left the cell.
private void grid_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
	if(e.RowIndex > 0 && e.ColIndex > 0)
	{
		dataTable1.Rows[e.RowIndex - 1][e.ColIndex - 1] = e.Style.CellValue;
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon