Hi,
I've implemented a nested view template very similar to the example Nested View Template however I am implementing Edit and Insert of items into grids that reside in the template. On updates I'll be fine but on inserts, what I need is the datakey of the expanded row of the grid in the MasterTable.
Please see aspx below. When the user issues an Insert from the UserControl of grdEndorsements (AddEditEndorsement.ascx), what I need in order to complete the insert is the DataKeyNames="EntityID" from the expanded row of grdEntities. So the logic here is, the user expands the nested view under a given row in grdEntities, they see the grdEndorsements in the RadTabStrip/Multipage and they can insert a new item into grdEndorsements.
I know I can get the datakey name for grdEntities when it expands but I want to get it when the user actually inserts. It is possible that the user may expand more than one row in grdEntities and then go and insert into a row previously expanded. I've thought of a few possible solutions but open to suggestions.
What I've left out for brevity is the SQL data source of grdEndorsements. However, I bring it up since the Label ID="LabelEntityID" is the value I need to complete the insert, I use it as the parameter for the Data Source that feeds grdEndorsements and it works just fine. I'm just not sure how to get that value on insert.
Thanks.
<telerik:RadGrid ID="grdEntities" runat="server" Skin="Telerik" |
GridLines="None" AllowPaging="True" AllowSorting="True" Width="99%" AutoGenerateColumns="False" |
ShowStatusBar="True" Visible ="true" ShowFooter="True"> |
<ClientSettings> |
<Scrolling AllowScroll="False" /> |
<ClientEvents OnPopUpShowing="PopUpShowing" /> |
</ClientSettings> |
<AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /> |
<MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top" |
DataKeyNames="EntityID" NoMasterRecordsText="No Entities to Display." EditMode="PopUp" EditFormSettings-CaptionFormatString="Add or Edit Entity"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
<CommandItemSettings AddNewRecordText="Add New Entity" /> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridEditCommandColumn> |
</telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn UniqueName="EntityID" HeaderText="EntityID" DataField="EntityID" Visible="False" > |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn UniqueName="EntityType" HeaderText="EntityType" DataField="EntityType" Visible="False" > |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn UniqueName="EntityName" HeaderText="Name" DataField="EntityName" Visible="True" > |
</telerik:GridBoundColumn> |
</Columns> |
<EditFormSettings UserControlName="~/UserControls/AddEditEntity.ascx" EditFormType="WebUserControl" |
PopUpSettings-Modal="True" PopUpSettings-Width="550px" PopUpSettings-ZIndex="9900"> |
<EditColumn UniqueName="EditCommandColumn1"> |
</EditColumn> |
<PopUpSettings Modal="True" ZIndex="9900" Width="550px"></PopUpSettings> |
</EditFormSettings> |
<NestedViewTemplate> |
<asp:Label ID="LabelEntityID" Font-Bold="true" Font-Italic="true" Text='<%# Eval("EntityID") %>' Visible="false" runat="server" /> |
<asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap"> |
<telerik:RadTabStrip runat="server" ID="TabStip1" MultiPageID="Multipage1" SelectedIndex="0" Skin="Vista"> |
<Tabs> |
<telerik:RadTab runat="server" Text="Endorsements" PageViewID="PageView1"> |
</telerik:RadTab> |
</Tabs> |
</telerik:RadTabStrip> |
<telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false"> |
<telerik:RadPageView runat="server" ID="PageView1"> |
<telerik:RadGrid ID="grdEndorsements" runat="server" Skin="Web20" |
GridLines="None" AllowPaging="True" AllowSorting="True" Width="99%" AutoGenerateColumns="False" |
ShowStatusBar="True" Visible ="true" ShowFooter="True" DataSourceID="SDSGetEndorsements"> |
<MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand" |
DataKeyNames="EndorsementID" NoMasterRecordsText="No Endorsements to Display." PageSize="5" |
EditMode="PopUp" EditFormSettings-CaptionFormatString="Add or Edit Endorsement"> |
<CommandItemSettings AddNewRecordText="Add New Endorsement" /> |
<Columns> |
<telerik:GridEditCommandColumn> |
</telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn UniqueName="EndorsementID" HeaderText="EndorsementID" DataField="EndorsementID" Visible="False" > |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn UniqueName="EntityID" HeaderText="EntityID" DataField="EntityID" Visible="False" > |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn UniqueName="EndorsementName" HeaderText="Name" DataField="EndorsementName" Visible="True" > |
</telerik:GridBoundColumn> |
</Columns> |
<EditFormSettings UserControlName="~/UserControls/AddEditEndorsement.ascx" EditFormType="WebUserControl"> |
<EditColumn UniqueName="EditCommandColumnE1"> |
</EditColumn> |
<PopUpSettings Modal="True" ZIndex="9900" Width="550px"></PopUpSettings> |
</EditFormSettings> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
</MasterTableView> |
<ClientSettings> |
<ClientEvents OnPopUpShowing="PopUpShowing" /> |
<Scrolling AllowScroll="False" /> |
</ClientSettings> |
<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" /> |
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /> |
<AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /> |
</telerik:RadGrid> |
</telerik:RadPageView> |
</telerik:RadMultiPage> |
</asp:Panel> |
</NestedViewTemplate> |
</MasterTableView> |
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /> |
<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" /> |
</telerik:RadGrid> |