Problem with dataKeyField

F

Flare

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
 
A

Alvin Bruney [MVP]

is your "ID" field the primary key in the database? it has to be for this to
work
 

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
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top