Gridview rowupdating method

30 Nov

To do this we first need to obtain the reference of the current row by using its index no as shown in the first line below.

By using the Grid View Row object we can find the reference of any control in the row in which user is editing the data.

This collection only requires the row index no and it will give us the primary key.

Last line of the following code is calling a local method for updating the database and passing all the parameters to this method.

A couple of days ago I mentioned a project that I’ve been working on that is a bit out of the ordinary as far as Grid Views go.

One of the issues I’ve had is that the edit template doesn’t map to the view template very well. You see, the data that gets stored back to the database during the edit could go to two of four different tables.

These properties will automatically render Edit, Update and Cancel buttons inside Grid View column.

I am using Template Field’s Item Template and Edit Item Template for providing read only and editing interface of the same column in the Grid View.

I would need to set values passed to the Sql Data Source control on the update event, and as part of this I would need to reference the controls contained in the row being updated.

NET page that will handle different Grid View events to provide complete editing functionality.

In the Page_Load event, you simply load your data from the database and bind it with the Grid View control as shown below: For brevity I am not storing connection string in the web.config and also not using any Data Access Component.

But the view is generated from a stored procedure that gathers the information from those tables and makes the result look like it came from one table. NET, C#, Node.js, Java Script, HTML, CSS, Boot Strap, and Angular. Does your team need additional help in any of the above?

So how do you have the Grid View update the database under these conditions?