Bind List within List to DataGrid
I have class A Collection
In Class A I have class b collection
Now I want to bind Class b property to gridview with use of C# binding syntax without write any code in code behind item or in gridview event
can any buddy开发者_Go百科 help me.
Problem
i have a list "A" which have a list "B" within it and B have a property C now i want to bind C
means i will bind A as datasource to grid and for column i want "B[0].C
Try something like this
GridView1.DataSource = A;
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# ((YourCollectionType)Eval("B"))[0].C %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
精彩评论