Row keys for an ASP.NET 2.0 GridView

ASP.NET 2.0 GridView can use DataKeyNames to store row key values and retrieve them later through the DataKeys property.

.NET

I only just discovered this today, that if you tell a GridView control via its DataKeyNames property what the key column for each row is, then you can retrieve that value later by using the DataKeys property.

eg.

Dim sectionId As Integer = CInt(GridView1.DataKeys(row.RowIndex).Value)