Rowupdating get values

22-May-2019 09:36

In data driven web sites, users are normally allowed to view data and administrators are allowed to add, edit or delete data.

In this tutorial I will show you how you can create an editable Grid View control for administrators to modify database records directly into the Grid View control.

Then we need to override the gridview's Row Updating event.

In this event you can write code to get the newvalue of checkbox's checked property only.

rowupdating get values-62rowupdating get values-86rowupdating get values-8

But unfortunately the Bind is not available in ASP. We could still achieve this in two simple and easy steps. Wrap the Eval(fieldname) HTML code in a function eg: Checkvalue that checks the datafield value, performs transformations to True OR False values and assigns to Chekced property. Override the Row Updating event of gridview and update only the Checked property's value since the SQLData Source that is bound to gridview will take care of remaining fields to update.For this situation, many developers use invisible columns (Hidden columns) in the gridview to identify that row. We can achieve the same functionality using Datakeys. Do you want to have your say when we set our development plans?Do you want to know when a feature you care about is added or when a bug fixed?

But unfortunately the Bind is not available in ASP. We could still achieve this in two simple and easy steps. Wrap the Eval(fieldname) HTML code in a function eg: Checkvalue that checks the datafield value, performs transformations to True OR False values and assigns to Chekced property. Override the Row Updating event of gridview and update only the Checked property's value since the SQLData Source that is bound to gridview will take care of remaining fields to update.

For this situation, many developers use invisible columns (Hidden columns) in the gridview to identify that row.

We can achieve the same functionality using Datakeys.

Do you want to have your say when we set our development plans?

Do you want to know when a feature you care about is added or when a bug fixed?

In this example, I am going to retrieve values from categories table of Northwind database. Drag a Grid View into the Web Form and assign Data Key Names property with the primary key column i.e. In the gdview_Row Editing and gdview_Row Deleting event, we have used the below code to retrieve categoryid from datakey of Grid View, int catid = int.