C rowupdating datakey
We can achieve the same functionality using Datakeys. 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. Take a look at the page load if you are binding on post back then the values get updated before you are able to access them.
Table Name- Employees Fields- Emp Id, Emp Name, Designation Take Grid View control on page and set the ID property to dg Employees.string connetion String = "YOUR_CONSTR" ; string upd Stmt = "UPDATE Quantity set [email protected]_pro4, [email protected]_pro5, [email protected]_profile5 " "where [email protected] Name"; using (Sql Connection cnn = new Sql Connection(connetion String)) I have tested this code, and it reads the table, and allows the edits of the records. Make sure the parameters on the update match the field names (@branch Name, @Parent Id). Instead of looping you can use a linq query on your datasource like if your datasource is a list, obj = l Objs. A datakey represents the primary key field or field of a record that can uniquely identify it in a data-bound control. Row Index represents the index of the particular row.