In this tutorial we are searching for our Text Box controls txt Product Name and txt Unit Price.To get the Primary Key reference we can use the Data Keys collection of the Grid View.These properties will automatically render Edit, Update and Cancel buttons inside Grid View column.
We define a connection in the web.config file and give a name to the connection string.
Now we access this connection string on the page so we can open a connection with the relation database. The first one accesses the connection string and the other is for the SQL connection.
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.
The Edit Index property of a Grid View determines the index of a row in edit mode. Update record and get updated state of the Grid View.
When a Grid View row is in edit mode then we can update the row's record in the relational database table.So we need to create a Stored Procedure on which we pass all parameters that are updateable along with the primary key value, in other words the row data's key value that is being updated.We use the Row Updating event of Grid View to update the record in the database table.So first we need to move to an updateable row record in the Text Box.To do that we need a Row Editing event of the Grid View.Next event is the Grid View Row Editing event to give ASP. You need to set the Edit Index property of the Grid View with the New Edit Index property of the Grid View Edit Event Args class.