Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the DataKeyNames in aspx in codebehind?

I need to get the DataKeyNames in codebehind of my ASP.NET application (VB.NET). How can I get that?

like image 906
Nandini Avatar asked Jan 31 '26 08:01

Nandini


1 Answers

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.

like image 64
splattne Avatar answered Feb 03 '26 05:02

splattne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!