I have Tables Customer and Two nested Table(Order and OrderDetais). the problem is i have to
add the detail table (GridTableView) if the item is expanded
so far i solve the Customer To display the Order Table but when i try to expand
Order table to display The OrderDetails it wont show up how do i do this
Note: GridTableView will must be added only/during item expand
Customer
Order
OrderDetails
add the detail table (GridTableView) if the item is expanded
so far i solve the Customer To display the Order Table but when i try to expand
Order table to display The OrderDetails it wont show up how do i do this
Note: GridTableView will must be added only/during item expand
Customer
Order
OrderDetails
| protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) |
| { |
| if (e.DetailTableView.DataSourceID == "") |
| { |
| SqlDataSource2.SelectParameters["CustomerID"].DefaultValue = e.DetailTableView.ParentItem.GetDataKeyValue("CustomerID").ToString(); |
| e.DetailTableView.DataSource = SqlDataSource2; |
| GridTableView tableViewOrders = new GridTableView(RadGrid1); |
| tableViewOrders.DataSource = SqlDataSource3; |
| tableViewOrders.Width = Unit.Percentage(100); |
| tableViewOrders.AutoGenerateColumns = true; |
| tableViewOrders.DataKeyNames = new string[] { "OrderID" }; |
| tableViewOrders.HierarchyLoadMode = GridChildLoadMode.ServerOnDemand; |
| GridRelationFields relationFields = new GridRelationFields(); |
| relationFields.MasterKeyField = "OrderID"; |
| relationFields.DetailKeyField = "OrderID"; |
| tableViewOrders.ParentTableRelation.Add(relationFields); |
| e.DetailTableView.DetailTables.Add(tableViewOrders); |
| e.DetailTableView.ID = "NestedOrder"; |
| } |
| } |
| <asp:SqlDataSource ID="SqlDataSource1" |
| ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" |
| ProviderName="System.Data.SqlClient" |
| SelectCommand="SELECT * FROM Customers" runat="server"></asp:SqlDataSource> |
| <asp:SqlDataSource ID="SqlDataSource2" |
| ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" |
| ProviderName="System.Data.SqlClient" |
| SelectCommand="SELECT * FROM Orders Where CustomerID = @CustomerID" runat="server"> |
| <SelectParameters> |
| <asp:Parameter Name="CustomerID" Type="string" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |
| <asp:SqlDataSource ID="SqlDataSource3" |
| ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" |
| ProviderName="System.Data.SqlClient" |
| SelectCommand="SELECT * FROM [Order Details] where OrderID = @OrderID" runat="server"> |
| <SelectParameters> |
| <asp:Parameter Name="OrderID" Type="Int32" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |
| <telerik:RadGrid id="RadGrid1" DataSourceID="SqlDataSource1" |
| ShowStatusBar="true" runat="server" AllowPaging="True" |
| AllowSorting="True" AllowAutomaticUpdates="True" |
| OnItemCommand="RadGrid1_ItemCommand" OnDetailTableDataBind="RadGrid1_DetailTableDataBind"> |
| <MasterTableView PageSize="10" DataKeyNames="CustomerID"> |
| <DetailTables> |
| <telerik:GridTableView></telerik:GridTableView> |
| </DetailTables> |
| <ExpandCollapseColumn Visible="True"></ExpandCollapseColumn> |
| </MasterTableView> |
| <ClientSettings EnableRowHoverStyle="true"> |
| <Selecting AllowRowSelect="true" /> |
| <ClientEvents OnRowDblClick="RowDblClick" /> |
| </ClientSettings> |
| </telerik:RadGrid> |