I have a FormView that uses an ObjectDataSource to retrieve a business object that contains a collection of children objects. I wanted to display the children in a GridView and it turns out to be very easy to do using Eval:
<asp:GridView ID="GridView1" runat="server" Visible='<%# Eval("HasChildren") %>'
AutoGenerateColumns="False" DataSource='<%# Eval("ChildrenApplications") %>'>
<Columns>
<asp:BoundField DataField="EAAppNum" HeaderText="EA ID" SortExpression="EaIdNegative" />
<asp:HyperLinkField DataNavigateUrlFormatString="ApplicationForm.aspx?pid={0}" DataNavigateUrlFields="ID"
DataTextField="Name" HeaderText="Name" SortExpression="Name" />
</Columns>
</asp:GridView>
1 comment:
Simple and exactly what I needed! Thanks for the post, you've just brought my train of thought back to the land of practical.
Post a Comment