Asp net rowupdating findcontrol
Last line of the following code is calling a local method for updating the database and passing all the parameters to this method.
Please keep in mind that there are many different ways to update the database using the Grid View control depending on the type of data you are updating and the functionality the user need and there are many solutions to achieve the same end result.
In the above tutorial I tried to give you one of the easiest solutions and I hope you can go explore Grid View control editing further after learning the basics from this tutorial.
In the Row Updating event I cannot gain access to any identifier that will enable me to start getting the updated values, update my object and persist it back to the database.
Now I will show you the C# code behind file of the above ASP.
NET page that will handle different Grid View events to provide complete editing functionality.
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.
In this tutorial we are searching for our Text Box controls txt Product Name and txt Unit Price.
The visitors to a web site can typically be divided into two groups: the users and the administrators.
If user clicks the Cancel button while Grid View is in editing mode, you need to Cancel the Editing process and also need to reset the Edit Index property to -1 in the Row Canceling Edit event of the Grid View control as shown below: The last step is to handle the Row Updating event to actually update the back end database.
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.
To get the Primary Key reference we can use the Data Keys collection of the Grid View.
This collection only requires the row index no and it will give us the primary key.