DataGrid - DataKeyField!!

Discussion in 'ASP .Net' started by Adam Knight, Aug 7, 2005.

  1. Adam Knight

    Adam Knight Guest

    I have a datagrid like so:

    <asp:DataGrid ID="dgSubAreas" Runat="server"
    AutoGenerateColumns="False"
    DataKeyField=""
    DataSource='<%#
    Container.DataItem.Row.GetChildRows("relSubAreas") %>'>

    Its data source is the result of a table relation created like this:
    ds.Relations.Add("relSubAreas", ds.Tables("Areas").Columns("area_id"),
    ds.Tables("SubAreas").Columns("parent_id"))

    When i try to set its datakeyfield attribute to a column name 'area_id' i
    get an error.
    Something to the effect that datarow doesn't contain a property called
    area_id.
    If is use <%# Container.DataItem("area_id") within the control itself it is
    fine.

    Can someone enlighten me on how to set the datakeyfield to draw the right
    data "area_id".
    Cheers,
    Adam
     
    Adam Knight, Aug 7, 2005
    #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. Homer J. Simpson
    Replies:
    2
    Views:
    1,127
    Suresh
    Mar 5, 2004
  2. Sean

    how to get datagrid item index from DataKeyField value?

    Sean, Aug 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    885
    Arthur
    Aug 7, 2003
  3. A. Atienza

    DataGrid's DataKeyField Value (C#)

    A. Atienza, Dec 7, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    363
    Michael Tkachev
    Dec 7, 2004
  4. Stephen Woolhead

    Datagrid DataKeyField and Webservice Proxy Objects

    Stephen Woolhead, Dec 16, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    172
    Stephen Woolhead
    Dec 20, 2004
  5. Kylin

    How to get the DataKeyField in the DataGrid ?

    Kylin, May 31, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    499
    Brock Allen
    May 31, 2005
Loading...

Share This Page