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

Updating inserted grid row with a newly assigned ID value


Given the following simple grid:



ConnectionString="<%$ ConnectionStrings:PrimaryDS %>"
SelectCommand="SELECT [DisplayText], [SortOrder], [CommodityGroupId] as Id FROM [CommodityGroups] ORDER BY [SortOrder], [DisplayText]"
InsertCommand="AddCommodityGroup" InsertCommandType="StoredProcedure">









What is necessary to get the value of the output parameter (Id) into the corresponding grid row?



1 Reply

BM Balaji M Syncfusion Team July 21, 2009 12:17 PM UTC

Hi John,

Thank you for your interest in Syncfusion products.

We would suggest you to use the GridGroupingControl1.Table.CurrentRecord.SetValue method, in order to set the value to grid row (#ID value returned from output parameter).

Please find the updated sample from the below link.
http://files.syncfusion.com/support/GGC.Web/7.2.0.20/58127/sample1.zip

The Sample illustrates,

1. EmployeeID is ReadOnly Column.

2. During ondatasourcecontrolrowadding event, EmployeeId value is passed as 1 [Some Default value for to avoid Null exception ]. Please refer the following code snippet.

protected void GridGroupingControl1_DataSourceControlRowAdding(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridDataSourceControlRowAddingEventArgs e)
{
e.NewValues["EmployeeID"] = 1;
e.Handled = true;
}


3. In SqlDataSource1_Inserted event, EmployeeID value accessed through output parameter and the current record is updated with this value. Please refer the following code snippet.

protected void SqlDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
string empID = e.Command.Parameters["@EmployeeID"].Value.ToString();
Record rec = this.GridGroupingControl1.Table.CurrentRecord;
rec.SetValue("EmployeeID", empID);
}


Please let me know if you have any concerns.

Regards,
M. Balaji

Loader.
Live Chat Icon For mobile
Up arrow icon