J
jerome.avoustin
Hi All !
I got some pbs with binding objects in ASP.Net 2.0
I've got such an object composition :
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public Car Car { get; set; }
}
class Car
{
public string Type { get; set; }
public string Color { get; set; }
}
I build a List<Person> and try to bind it to a GridView
Here's my GridView :
<asp:GridView ID="gdvTest" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="Name" DataField="Name"/>
<asp:BoundField HeaderText="Age" DataField="Age"/>
</Columns>
</asp:GridView>
Then I try to bind values from the car
I try either this... :
<asp:BoundField HeaderText="Car Type" DataField="Car.Type"/>
.... Or this :
<asp:TemplateField HeaderText="Car Type">
<ItemTemplate>
<%# DataBinder.Eval(Container, "Car.Type") %>
Or
<%# DataBinder.Eval(Container,
"Personne.Car.Type") %>
</ItemTemplate>
</asp:TemplateField>
I always get an exception :
Impossible to find a fiels or a propertie 'Car.Type' in the datasource
or
DataBinding : 'System.Web.UI.WebControls.GridViewRow' has no propertie
calld 'Car'. (traduction from french)
Has someone any idea ?
Thanx !
I got some pbs with binding objects in ASP.Net 2.0
I've got such an object composition :
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public Car Car { get; set; }
}
class Car
{
public string Type { get; set; }
public string Color { get; set; }
}
I build a List<Person> and try to bind it to a GridView
Here's my GridView :
<asp:GridView ID="gdvTest" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="Name" DataField="Name"/>
<asp:BoundField HeaderText="Age" DataField="Age"/>
</Columns>
</asp:GridView>
Then I try to bind values from the car
I try either this... :
<asp:BoundField HeaderText="Car Type" DataField="Car.Type"/>
.... Or this :
<asp:TemplateField HeaderText="Car Type">
<ItemTemplate>
<%# DataBinder.Eval(Container, "Car.Type") %>
Or
<%# DataBinder.Eval(Container,
"Personne.Car.Type") %>
</ItemTemplate>
</asp:TemplateField>
I always get an exception :
Impossible to find a fiels or a propertie 'Car.Type' in the datasource
or
DataBinding : 'System.Web.UI.WebControls.GridViewRow' has no propertie
calld 'Car'. (traduction from french)
Has someone any idea ?
Thanx !