How to avoid hardcoding DataKeyField name ?

Discussion in 'ASP .Net Datagrid Control' started by Jeff Robichaud, Aug 22, 2006.

  1. Hi,

    How can I avoid hardcoding the name of the DataKeyField property of a
    DataGrid ?

    Like:

    datagrid.DataSource = someSource;
    datagrid.DataKeyField = "employeeId";

    The above works but it's not what I want, because whenever the name of the
    field changes, I'm screwed. Avoiding this is the purpose of strongly-typed
    datasets (or using collections or whatever data layer abstraction mechanism
    you like) as I understand it, but I'd like to know what you n-tier gurus do
    in this case ?

    Thanks,
    - Jeff
    Jeff Robichaud, Aug 22, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alen Smith

    datagrid hardcoding...

    Alen Smith, Jun 30, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    1,601
    Alen Smith
    Jun 30, 2005
  2. Gyruss
    Replies:
    6
    Views:
    4,107
    Kenneth P. Turvey
    Jun 20, 2005
  3. cgian31
    Replies:
    11
    Views:
    765
    Oliver Wong
    Oct 21, 2005
  4. cgian31
    Replies:
    1
    Views:
    390
  5. Kyler Laird
    Replies:
    0
    Views:
    316
    Kyler Laird
    Dec 27, 2003
Loading...

Share This Page