I have a complex scenario where I have a RadGrid that contains a GridTableView, and that GridTableView needs a RadComboBox in the CommandItemTemplate whose item list needs to load dynamically based on the selected item in the parent grid. When an item is selected in the combo, it needs to insert a record into the GridTableView. The grid looks something like:
<telerik:RadGrid ID="MeetingRoomsGrid" runat="server" OnDetailTableDataBind="MeetingRoomsGrid_DetailTableDataBind">
<MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="Id" EditMode="InPlace" InsertItemPageIndexAction="ShowItemOnFirstPage">
<CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowExportToCsvButton="true" />
<DetailTables>
<telerik:GridTableView DataKeyNames="Id" Name="Aggregates" Width="100%" AllowSorting="true" AllowFilteringByColumn="true" CommandItemDisplay="Top">
<CommandItemTemplate>
<div style="float: right;">
<telerik:RadComboBox ID="AggregateRoomCombo" runat="server" AutoPostBack="true" OnSelectedIndexChanged="AggregateRoomCombo_SelectedIndexChanged">
<Items>
<telerik:RadComboBoxItem Text="foo" />
<telerik:RadComboBoxItem Text="bar" />
</Items>
</telerik:RadComboBox>
</div>
<div class="clearfix"> </div>
</CommandItemTemplate>
<Columns>
<telerik:GridBoundColumn DataField="ChildName" DataType="System.String" UniqueName="ChildName" SortExpression="ChildName" />
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" ButtonType="ImageButton">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridButtonColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridEditCommandColumn UniqueName="EditColumn" ButtonType="ImageButton">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn DataField="Name"
DataType="System.String"
UniqueName="Name"
SortExpression="Name"
DefaultInsertValue="New Meeting Room"
ItemStyle-Width="210">
<ItemTemplate>
<asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
(I have stripped out a bunch of stuff to try to pare it down to the essential essence)
So on the MeetingRoomsGrid_DetailDataBind() event I need to find the AggregateRoomCombo and load items into it based on the Id of the selected data item in the grid, and on the AggregateRoomCombo_SelectedIndexChanged() event I need to insert a new record into the detail table based on the Id of the selected data item in the grid.
Can anyone tell me how to traverse the grid object model to 1) find the AggregateRoomCombo object in the detail table, and 2) traverse backwards from the AggregateRoomCombo up to the grid to find the Id of the selected data item?
<telerik:RadGrid ID="MeetingRoomsGrid" runat="server" OnDetailTableDataBind="MeetingRoomsGrid_DetailTableDataBind">
<MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="Id" EditMode="InPlace" InsertItemPageIndexAction="ShowItemOnFirstPage">
<CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowExportToCsvButton="true" />
<DetailTables>
<telerik:GridTableView DataKeyNames="Id" Name="Aggregates" Width="100%" AllowSorting="true" AllowFilteringByColumn="true" CommandItemDisplay="Top">
<CommandItemTemplate>
<div style="float: right;">
<telerik:RadComboBox ID="AggregateRoomCombo" runat="server" AutoPostBack="true" OnSelectedIndexChanged="AggregateRoomCombo_SelectedIndexChanged">
<Items>
<telerik:RadComboBoxItem Text="foo" />
<telerik:RadComboBoxItem Text="bar" />
</Items>
</telerik:RadComboBox>
</div>
<div class="clearfix"> </div>
</CommandItemTemplate>
<Columns>
<telerik:GridBoundColumn DataField="ChildName" DataType="System.String" UniqueName="ChildName" SortExpression="ChildName" />
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" ButtonType="ImageButton">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridButtonColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridEditCommandColumn UniqueName="EditColumn" ButtonType="ImageButton">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn DataField="Name"
DataType="System.String"
UniqueName="Name"
SortExpression="Name"
DefaultInsertValue="New Meeting Room"
ItemStyle-Width="210">
<ItemTemplate>
<asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
(I have stripped out a bunch of stuff to try to pare it down to the essential essence)
So on the MeetingRoomsGrid_DetailDataBind() event I need to find the AggregateRoomCombo and load items into it based on the Id of the selected data item in the grid, and on the AggregateRoomCombo_SelectedIndexChanged() event I need to insert a new record into the detail table based on the Id of the selected data item in the grid.
Can anyone tell me how to traverse the grid object model to 1) find the AggregateRoomCombo object in the detail table, and 2) traverse backwards from the AggregateRoomCombo up to the grid to find the Id of the selected data item?