I have three master /detail RadGrids like:
--1
----2
------3
I am trying to ensure two scenarios:
How can I make sure the appropriate rows are selected and the correct child data loaded for when the page loads and the user clicks a row in any grid?
I tried accessing the SelectedItems during Page_PreRender but only succeeded in selecting the first rows on page load, not when the user clicks a row. I tried the solution found on this site to always select a row but the code did not work for me.
Richard
Here is some source:
aspx
--1
----2
------3
I am trying to ensure two scenarios:
How can I make sure the appropriate rows are selected and the correct child data loaded for when the page loads and the user clicks a row in any grid?
I tried accessing the SelectedItems during Page_PreRender but only succeeded in selecting the first rows on page load, not when the user clicks a row. I tried the solution found on this site to always select a row but the code did not work for me.
Richard
Here is some source:
aspx
<telerik:RadGrid AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AutoGenerateEditColumn="true" DataSourceID="FirstDataSource" Height="380" ID="FirstGrid" OnDeleteCommand="Grid_OnCommand" OnInsertCommand="Grid_OnCommand" OnItemDeleted="Grid_OnItemDeleted" OnItemInserted="Grid_OnItemInserted" OnItemUpdated="Grid_OnItemUpdated" OnUpdateCommand="Grid_OnCommand" runat="server"> <MasterTableView DataKeyNames="Id"> <Columns> <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="System Id" ReadOnly="True" UniqueName="FirstId"> </telerik:GridBoundColumn> <telerik:GridButtonColumn ButtonType="LinkButton" CommandName="Delete" ConfirmText="Delete this record?\n\nThis action cannot be undone." Text="Delete" UniqueName="DeleteFirst"> </telerik:GridButtonColumn> </Columns> </MasterTableView> <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true"> <Selecting AllowRowSelect="true" /> <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" /> </ClientSettings> </telerik:RadGrid> <telerik:RadGrid AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AutoGenerateEditColumn="true" DataSourceID="SecondDataSource" Height="380" ID="SecondGrid" OnDeleteCommand="Grid_OnCommand" OnInsertCommand="Grid_OnCommand" OnItemDeleted="Grid_OnItemDeleted" OnItemInserted="Grid_OnItemInserted" OnItemUpdated="Grid_OnItemUpdated" OnUpdateCommand="Grid_OnCommand" runat="server"> <MasterTableView DataKeyNames="Id"> <Columns> <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="System Id" ReadOnly="True" UniqueName="SecondId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="FirstId" DataType="System.Int32" ForceExtractValue="Always" ReadOnly="True" UniqueName="FirstId" Visible="false"> </telerik:GridBoundColumn> <telerik:GridButtonColumn ButtonType="LinkButton" CommandName="Delete" ConfirmText="Delete this record?\n\nThis action cannot be undone." Text="Delete" UniqueName="DeleteSecond"> </telerik:GridButtonColumn> </Columns> </MasterTableView> <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true"> <Selecting AllowRowSelect="true" /> <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" /> </ClientSettings> </telerik:RadGrid> <telerik:RadGrid AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AutoGenerateEditColumn="true" DataSourceID="ThirdDataSource" Height="380" ID="ThirdGrid" OnDeleteCommand="Grid_OnCommand" OnInsertCommand="Grid_OnCommand" OnItemDeleted="Grid_OnItemDeleted" OnItemInserted="Grid_OnItemInserted" OnItemUpdated="Grid_OnItemUpdated" OnUpdateCommand="Grid_OnCommand" runat="server"> <MasterTableView DataKeyNames="Id"> <Columns> <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="System Id" ReadOnly="True" UniqueName="ThirdId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="SecondId" DataType="System.Int32" ForceExtractValue="Always" ReadOnly="True" UniqueName="SecondId" Visible="false"> </telerik:GridBoundColumn> <telerik:GridButtonColumn ButtonType="LinkButton" CommandName="Delete" ConfirmText="Delete this record?\n\nThis action cannot be undone." Text="Delete" UniqueName="DeleteThird"> </telerik:GridButtonColumn> </Columns> </MasterTableView> <ClientSettings> <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" /> </ClientSettings> </telerik:RadGrid> </telerik:RadPane> </telerik:RadSplitter> <asp:EntityDataSource ConnectionString="name=Entities" DefaultContainerName="Entities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="Firsts" EntityTypeFilter="First" ID="FirstDataSource" runat="server"> </asp:EntityDataSource> <asp:EntityDataSource ConnectionString="name=Entities" DefaultContainerName="Entities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="Seconds" EntityTypeFilter="Second" ID="SecondDataSource" runat="server" Where="it.[FirstId] = @FirstId"> <WhereParameters> <asp:ControlParameter ControlID="FirstGrid" DefaultValue="0" Name="FirstId" PropertyName="SelectedValue" Type="Int32" /> </WhereParameters> </asp:EntityDataSource> <asp:EntityDataSource ConnectionString="name=Entities" DefaultContainerName="Entities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="Thirds" EntityTypeFilter="Third" ID="ThirdDataSource" runat="server" Where="it.[SecondId] = @SecondId"> <WhereParameters> <asp:ControlParameter ControlID="SecondGrid" DefaultValue="0" Name="SecondId" PropertyName="SelectedValue" Type="Int32" /> </WhereParameters> </asp:EntityDataSource>