1

i have class bound to repeater as a list here is structure of class

public String Name { get; set; }
public String Description { get; set; }
public List<ProductRecord> ProductList { get; set; }

i can get Eval("Name") on aspx page. How do i go about accessing ProductList properties in Eval e.g ProductRecord has Name property

Thank you in advance

jjj
  • 1,136
  • 3
  • 18
  • 28
Rain
  • 85
  • 11
  • Check this http://stackoverflow.com/questions/1130351/gridview-bound-with-properties-of-nested-class – Moe Nov 11 '15 at 20:11
  • Hi thanks for quick reply i am getting an error as i have list of products in my class Additional information: DataBinding: 'System.Collections.Generic.List`1[[ProductRecord, Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' does not contain a property with the name 'Name'. – Rain Nov 11 '15 at 20:43

1 Answers1

2

You need to tell the Eval which one of the multiple ProductRecord you want. The problem is that you want to navigate a 1 to many relationship and get a value from the many. You have to make it a 1 to 1 relationship. For this you could either specify a single element like:

Eval("ProductList[0].Name")

Another option would be to put ProductList on a new Repeater, so you can show all the ProductList's properties for your structure. Or concatenating all values into a single value for display.

Cat_Clan
  • 352
  • 2
  • 9
  • Hi Thanks for your reply. It makes sense now to use a new or sub repeater but if later in the future i will have sub products or type to display it will become messy to have another repeater. So i am thinking of using something else like bootstrap collapseable panels. I will have to do some digging on how to read data from asp.net code behind and display on page using bootstrap collapseable panels. By doing that i will have more control over data and reprenstation. Any suggestions please? – Rain Nov 12 '15 at 11:13
  • Not sure what you want to accomplish by using a bootstrap collapseable panels. Can you elaborate a bit more on it? – Cat_Clan Nov 17 '15 at 22:53