Easy Nested Datagrid
Nested Grid Example
ASPX Page
<asp:datagrid id="dgBids" onItemCommand="commandDGBid" headerStyle-CssClass="tdheaders" cellpadding="5" runat="server" autogeneratecolumns="false">
<columns>
<asp:BoundColumn dataField="company" headertext="Company"></asp:BoundColumn>
<asp:BoundColumn dataField="bidID" visible="false"></asp:BoundColumn>
<asp:ButtonColumn buttonType="LinkButton" dataTextField="bidid" CommandName="bid" headertext="Bid"></asp:ButtonColumn>
<asp:BoundColumn dataField="seasondesc" headertext="Season"></asp:BoundColumn>
<asp:BoundColumn dataField="style" headertext="Style"></asp:BoundColumn>
<asp:BoundColumn dataField="styledescription"></asp:BoundColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:datagrid id="dgDetail" headerstyle-cssclass="tdheaders" runat="server" autogeneratecolumns="false">
<Columns>
<asp:BoundColumn dataField="company"></asp:BoundColumn>
<asp:BoundColumn datafield="vendorid" headertext="Vendor"></asp:BoundColumn>
<asp:BoundColumn dataField="submittedDate"></asp:BoundColumn></Columns>
</asp:datagrid>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn dataField="closedate" headertext="Close Date"></asp:BoundColumn>
<asp:BoundColumn DataField="country" headertext="Country<br>of Origin"></asp:BoundColumn>
<asp:BoundColumn dataField="vendorsSelected" headertext="Vendors<br>Selected" itemstyle-horizontalalign="right"></asp:BoundColumn></columns>
</asp:datagrid>
BACKEND
Sub commandDGBid(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Dim bidid As Integer = e.Item.Cells(1).TextDim dg2 As DataGrid = e.Item.Cells(5).FindControl("dgDetail")
dg2.DataSource = VendorBid_Data.vendorBids.getBidDetail(bidid)
dg2.DataBind() End Sub
ASPX Page
<columns>
<asp:BoundColumn dataField="company" headertext="Company"></asp:BoundColumn>
<asp:BoundColumn dataField="bidID" visible="false"></asp:BoundColumn>
<asp:ButtonColumn buttonType="LinkButton" dataTextField="bidid" CommandName="bid" headertext="Bid"></asp:ButtonColumn>
<asp:BoundColumn dataField="seasondesc" headertext="Season"></asp:BoundColumn>
<asp:BoundColumn dataField="style" headertext="Style"></asp:BoundColumn>
<asp:BoundColumn dataField="styledescription"></asp:BoundColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:datagrid id="dgDetail" headerstyle-cssclass="tdheaders" runat="server" autogeneratecolumns="false">
<Columns>
<asp:BoundColumn dataField="company"></asp:BoundColumn>
<asp:BoundColumn datafield="vendorid" headertext="Vendor"></asp:BoundColumn>
<asp:BoundColumn dataField="submittedDate"></asp:BoundColumn></Columns>
</asp:datagrid>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn dataField="closedate" headertext="Close Date"></asp:BoundColumn>
<asp:BoundColumn DataField="country" headertext="Country<br>of Origin"></asp:BoundColumn>
<asp:BoundColumn dataField="vendorsSelected" headertext="Vendors<br>Selected" itemstyle-horizontalalign="right"></asp:BoundColumn></columns>
</asp:datagrid>
BACKEND
Sub commandDGBid(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Dim bidid As Integer = e.Item.Cells(1).TextDim dg2 As DataGrid = e.Item.Cells(5).FindControl("dgDetail")
dg2.DataSource = VendorBid_Data.vendorBids.getBidDetail(bidid)
dg2.DataBind() End Sub
Comments