Hi,
I need to get the DataKeyNames in codebehind of my ASP.NET application (VB.NET). How can I get that?
Hi,
I need to get the DataKeyNames in codebehind of my ASP.NET application (VB.NET). How can I get that?
This way (VB.NET code):
For Each dkn As String in GridView1.DataKeyNames
' -- Do something here with dkn
Next
DataKeyNames
is an array of strings, so there can be more than one in a GridView. You can access the array members this way (example):
Dim FirstKeyName as String = GridView1.DataKeyNames(0)
Here is the documentation on MSDN of the DataKeyNames
property.