O DataKeyNames, Where Art Thou?
The GridView control has a cool feature that allows you to bind more than one value as a DataKey. However, the documentation that I could find on how to get a DataKey other than the primary key was sparse. I finally discovered:
VB.NET
GridView.DataKeys(Index1).Values(Index2)
C#
GridView.DataKeys[Index1].Values[Index2]
Where GridView is the ID of the GridView control, Index1 is the index of the row in the GridView, and Index2 is the name of the DataKey.
R
Similar Posts
- Multiple DataKeys Null Conditional
- GridView Dynamic Button Frustrations
- GridView control didn't update or dissapeared. What gives?





Comments
Brendan on on 2.14.2006 at 5:42 AM
Ryan,
Thanks for this info.
I was about to give up using DataKeys. :-)
Regards,
Brendan