all groups > asp.net datagrid control > september 2004 >
You're in the

asp.net datagrid control

group:

Problem with dataKeyField


Problem with dataKeyField Flare
9/26/2004 7:52:47 PM
asp.net datagrid control:
Hi

Im having a problem with the DataKeyField and a array of a custom class.

I have eg. this class

class employee
{
public int ID
{ get / set }
public String Name
{ get / set }
}

I can do this
Employee emp[] = FACTORY.GetEmployees();
datagrid1.DataSource = emp; // OK
datagrid1.DataKeyField = "ID";

The error is:
Value cannot be null. Parameter name: container.

What am I doing wrong and how do I solve it. The employee class is en
reality an autogenerated O/R mapping class.

Thanks in regards
Anders

Re: Problem with dataKeyField Alvin Bruney [MVP]
9/27/2004 8:30:45 PM
is your "ID" field the primary key in the database? it has to be for this to
work

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
[quoted text, click to view]

AddThis Social Bookmark Button