Using LLBLGenProDataSource to bind GridView showing columns from two tables

Posts   
 
    
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 06-Nov-2007 13:31:39   

There, I think I've managed to describe it in the subject.

I'm using the LLBLGenProDataSource to populate GridView with my ProductCollection.

This collection has a foreign key of CategoryID which relates to the ProductCategoryCollection. What I would like to do is display the ProductCategoryEntity.Name in one of the columns - how would I do this?

Many thanks

Darren

jw
User
Posts: 10
Joined: 28-Jul-2005
# Posted on: 06-Nov-2007 16:06:11   

daz_oldham wrote:

There, I think I've managed to describe it in the subject.

I'm using the LLBLGenProDataSource to populate GridView with my ProductCollection.

This collection has a foreign key of CategoryID which relates to the ProductCategoryCollection. What I would like to do is display the ProductCategoryEntity.Name in one of the columns - how would I do this?

Many thanks

Darren

If using adapter, prefetch the Category entity. You cannot use a bound column, but if the CategoryID is NOT nullable, you can bind declaratively in your gridview via a template field. To bind to a label, you could do the following:

<asp:label text="<%# DataItem.ProductCategory.Name %>">

If the CategoryID IS nullable, you will have to handle in the rowdatabound event of the gridview.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 06-Nov-2007 20:09:52   

this thread may be helpful: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=10802

Another way to accomplish it is to create a typed/dynamic list instead.

daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 06-Nov-2007 20:42:44   

Thanks for the pointers JW/Goose - for some reason what wasn't working this morning suddenly is... maybe I'm more awake now wink

Darren