O DataKeyNames, Where Art Thou?

written by Ryan Olshan on Monday, December 05 2005

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

Kick this post on .NET Kicks

Similar Posts

  1. Multiple DataKeys Null Conditional
  2. GridView Dynamic Button Frustrations
  3. GridView control didn't update or dissapeared. What gives?

Comments

  • Brendan on on 2.14.2006 at 5:42 AM

    Brendan avatar

    Ryan,



    Thanks for this info.



    I was about to give up using DataKeys. :-)



    Regards,



    Brendan

Post a comment