Start Get datakey value gridview rowupdating

Get datakey value gridview rowupdating

Re-obtaining the List of objects via the utility method along with the index obtained from the event arg parameter is not an option because the List of objects may have changed.

To cancel the update operation, set the collections, if necessary, before the values are passed to the data source.

Create SQL Connection We need a connection with a Microsoft SQL Server database so we can access data and perform an operation on it.

We define a connection in the web.config file and give a name to the connection string.

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.

A common way to use these collections is to HTML-encode the values supplied by the user before they are stored in the data source.

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.

With a little bit of research, a lot bit of patience, and some help from the internet community, I was able to solve all my issues, and pretty elegantly at that. You can’t do something like Dim name As Hyper Link Dim inv As Text Box name = CType(Grid View1. in an actual post, just email me or comment somewhere and we’ll talk about it.