-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problems binding entity objects to a gridview
PostPosted: Tue Nov 21, 2006 7:12 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
Im using ASP.Net 2.0 and Nhibernate 1.2.0 beta


I have a DAO object that is returning a list of Client entity objects.


Im binding it to a grid view like this:

ClientsDAO clientDAO = new ClientsDAO();
IList results = clientDAO.Find(EmployerSearch_txtb.Text);
results_gv.DataSource = results;
results_gv.DataBind();

When is debug, im getting this exception:

"Data keys must be specified on GridView 'results_gv' before the selected data keys can be retrieved. Use the DataKeyNames property to specify data keys."

How do i get around this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 21, 2006 10:38 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
That isn't an NHibernate issue, but rather learning how to use the GridView in ASP.NET. I'd check the ASP.NET forums at www.asp.net.

_________________
If this helped...please remember to rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 21, 2006 12:05 pm 
Beginner
Beginner

Joined: Fri Dec 23, 2005 6:05 am
Posts: 42
I guess you need to specify your Datakeys in your Gridview. In other words you need to tell him which is the primary in your dataSource.
Example if your key is named "id" than it should look something like this:
Code:
<asp:GridView ID="myGridView" runat="server" AutoGenerateColumns="False" DataSourceID="codsArtikelliste"
                    DataKeyNames="Id" AllowPaging="True">...</asp:GridView>


Good luck, and btw. bosh is right, an ASP.NET forum would be a better try next time. :)

eg


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.