DataGrid - DataKeyField!!

A

Adam Knight

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top