Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Problem with dataKeyField

Reply
Thread Tools

Problem with dataKeyField

 
 
Flare
Guest
Posts: n/a
 
      09-26-2004
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


 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      09-28-2004
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
"Flare" <(E-Mail Removed)> wrote in message
news:%23z7fkG$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid - DataKeyField!! Adam Knight ASP .Net 0 08-07-2005 02:33 PM
Newbie question: ASP Datagrid + Complex DataKeyField Homer J. Simpson ASP .Net 2 03-05-2004 06:34 PM
DatakeyField with multi-column primary key Beryl Small ASP .Net 0 03-01-2004 12:24 AM
Composite DataKeyField? Felbrigg ASP .Net 4 02-11-2004 07:46 AM
datakeyfield and 3 fields making up the PK sramruttun ASP .Net 0 07-10-2003 06:49 AM



Advertisments