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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grouping Grid Example with DB Update

Thread ID:





86860 Jul 9,2009 06:50 PM UTC Jul 14,2009 12:23 PM UTC ASP.NET Web Forms (Classic) 3
Tags: GridGroupingControl
Administrator [Syncfusion]
Asked On July 9, 2009 06:50 PM UTC

Are there any examples (I couldn't find any) of the Grouping Grid where the database is updated with changes? I'm looking for an example that uses stored procedures to perform the updates.

Rekha P [Syncfusion]
Replied On July 10, 2009 01:36 PM UTC

Hi John,

Thank you for your interest in Syncfusion Products.

Please find a simple sample with stored procedures to perform the update operation in GridGroupingControl.



John Taylor
Replied On July 10, 2009 10:51 PM UTC

Thank you, Rekha.

Do you have anything that shows the process required to do the updates in code-behind? I'm not using the SqlDataSource controls.

I have my grid working for the display of data using a DataTable as the grid's DataSource, and a SqlDataAdapter to fill the Datatable. The problem I'm having is figuring out where to capture the updated grid records on postback, and how (if possible) to get the changed records back to database using SqlDataAdapter.

I had hoped that since DataSourceCachingMode="ViewState", I would be able to do something like:

DataTable dt = (DataTable)MyGrid.DataSource;
SqlDataAdapter da = new SqlDataAdapter();
da.UpdateCommand = GetUpdateCommand(conn);
da.InsertCommand = GetInsertCommand(conn);
da.DeleteCommand = GetDeleteCommand(conn);
da.SelectCommand = GetSelectCommand(conn);

However, that doesn't work because it appears that RowState is not preserved when the control is serialized. All rows in the DataTable are in "Unchanged" state.

Rekha P [Syncfusion]
Replied On July 14, 2009 12:23 PM UTC

Hi John,

You can use your custom sql query in DataSourceControlRowUpdating event, which occurs before updating a record in the bound DataSourceControl. Please refer the sample code snippet below to achieve this.

protected void GridGroupingControl1_DataSourceControlRowUpdating(object sender, GridDataSourceControlRowUpdateEventArgs e)
e.Cancel = true; //This will cancel the normal update in the datasource

//e will have all the values of the column in the Grid.
// your custom sql update query can be put up here.

e.Handled = true; //This will update the changes of the DataBase to the Grid.

If your intension is to know the row state when it is created, added, modified, and deleted, we would suggest you use SelectedRecordsChanged event in which the SelectedRecordsChangedType enumeration is returned by the Action property of the SelectedRecords.

void GridGroupingControl1_SelectedRecordsChanged(object sender, SelectedRecordsChangedEventArgs e)
if (e.Action == SelectedRecordsChangedType.Added)


Also you can use GridRowEditUpdateLink's OnClick event to trigger GridRowEditUpdateEventArgs which determines the type of the CommandLink. The command link type can be checked for:


Please refer the code snippet below to achieve this.



protected void RowEditUpdate(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridRowEditUpdateEventArgs e)
Label1.Text = "";
if (e.CommandLinkType == "Update")
Label1.Text = "Update Link is clicked";
if (e.CommandLinkType == "Cancel")
Label1.Text = "Cancel Link is clicked";
if (e.CommandLinkType == "Edit")
Label1.Text = "Edit Link is clicked";


Please let me know if you have any concerns.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon