views:

39

answers:

1

Hi I have a Linq CodeBehind Function Like this

var result = from m in context.Products.Include(n=>n.Categories)
                 where m.IsActive == true
                 select m;

The m is Product Class which holds the list of categories.

On the ASPX page in repeater I want to have acces to first category where my product is. I tried tu use code like:

<a class="more" href="medication_details.aspx?id=<%# Eval("Categories.ID") %>> 

The #Eval throws an error that Categories does not hold the property ID, and I think it's because products and categories are in relation one to many. how can I make in the aspx page reference like Categories[0].ID or sommthing??

A: 

You can try this:

<a class="more" href="medication_details.aspx?id=<%# Eval("Categories[0].ID") %>">more..</a>  
Krunal
Ye that's the answer ;) I thought it was just to obvious to work and didn't try it :)
shin