Databinding entity with graph to asp.net repeater

Posts   
 
    
Posts: 497
Joined: 08-Apr-2004
# Posted on: 27-Mar-2008 14:42:09   

Hi,

I have an entity which I have fetched from the database, along with a lot of the related data which I specified by using a couple of prefetch paths. My graph looks like this

Checklist -> 1:N -> Questions -> 1:1 Question_Response

So my checklist entity has many questions, each of which have a single response. Data retrieval is fine simple_smile

So, I need to display all the questions in the asp.net page, along with the response. I have added a repeater and databound to the EntityCollection of Questions, but this only gives me access to the Question entities, like this:

<label>Question:</label> <%# Eval("QuestionText") %>

What I then want to do is display the answer, but I don't know how to do this.. I need to tell the repeater to get it from the underlying Querstion's related answer, but I don't know an easy way to do this - all I can think of is to code it all manually in the OnItemDataBound like this ;-

{ myResponseLabel.Text = thisQuestion.Response.Answer; .. and so on for other fields }

Is this the only option I have, or is there a nice simple way to get this done ?

Thanks all!

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Mar-2008 15:02:05   
Posts: 497
Joined: 08-Apr-2004
# Posted on: 27-Mar-2008 15:05:50   

Man, thats so obvious I didn't even try it!

Thanks!