DataKey Collection Won't populate

J

JD

I cannot for the life of me figure out why my DataKeys collection won't
populate.

in the .aspx page I set DataKeyField="ID",
my datasource is a class which implementes IEnumerable. The items held by
my class do have an ID property.

I am attempting to use my DataKeys in a button event:

private void Received_Click(object sender, System.EventArgs e)

{
Response.Write( Grid.DataKeys.Count )
/*
string queryString="";

for(int i = 0 ; i < GridItems.Count; i++)
{
CheckBox blah= (CheckBox)Grid.Items.Controls[0].Controls[1];
if( blah.Checked )
queryString = queryString + Grid.DataKeys.Text() +",";

}
*/
}

The size of DataKeys is always 0. What really confuses me is that when I
assign the DataKeyField to a non-existent property, I never get an error
message. This makes me think that I have disabled DataKeys somehow.

Any insight into this...I'm totally stumped!

JD
 

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

Forum statistics

Threads
474,142
Messages
2,570,819
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top