consider the following classes (similar to the ones i am working with):
namespace Project
{
public class Person
{
public Person()
{
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private List<Pet> myPets;
public List<Pet> MyPets
{
get { return myPets; }
set { myPets = value; }
}
}
}
namespace Project
{
public class Pet
{
public Pet()
{
}
private int numberOfPaws;
public int NumberOfPaws
{
get { return numberOfPaws; }
set { numberOfPaws = value; }
}
}
}
Lets just say i bound my gridview to a List<Person>,
if i had template fields in the gridview markup how would I use Databinder.Eval() function to display 'numberOfPaws' for a pet at a certain index
eg.
<Gridview datasource=generic list of person>
<columns>
<TemplateField>
<ItemTemplate>
<asp: Label id="person" text="<% #Eval(Person.name) %>"></Label>
</ItemTemplate>
</TemplateField>
<TemplateField>
<ItemTemplate>
<asp: Label id="id" Text="<% [B][U]# (Container.DataItem).MyPets[0].NumberOfPaws.ToString()[/U][/B] %>"></Label>
</ItemTemplate>
</TemplateField>
</columns>
</Gridview>
i get error saying "server tag is not well formed " so that highlight code isnt how to do it, any suggestions or rough guidance???