I have a NestedViewTemplate which is based on the demo. Unfortunately it cannot find the Panel within it. What's going on with it?
And so forth ...
Here's the codenehind.
The panel != null is there to obviously avoid failure but TBH it's pointless using the NestedViewTemplate if the codebehind isn't going to pick up the embedded control. It happens elsewhere in the code as well.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
DataSourceID
=
"SqlDataSource1"
GridLines
=
"None"
OnItemCommand
=
"RadGrid1_ItemCommand"
OnUpdateCommand
=
"RadGrid1_UpdateCommand1"
OnItemCreated
=
"RadGrid1_ItemCreated"
>
<
MasterTableView
DataSourceID
=
"SqlDataSource1"
Name
=
"Client"
CommandItemDisplay
=
"Top"
DataKeyNames
=
"account_id,contact_id1,user_id"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"user_id"
runat
=
"server"
CommandItemDisplay
=
"Top"
CommandItemSettings-AddNewRecordText
=
"Add New Accommodation"
Caption
=
"Accommodation"
DataSourceID
=
"SqlDataSource4"
Width
=
"100%"
AutoGenerateColumns
=
"false"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
Name
=
"Accommodation"
>
<
NestedViewTemplate
>
<
asp:Panel
runat
=
"server"
ID
=
"InnerContainer"
Visible
=
"false"
>
<
telerik:RadTabStrip
runat
=
"server"
ID
=
"AccommodationTabStrip"
MultiPageID
=
"MultiPage1"
SelectedIndex
=
"1"
>
<
Tabs
>
<
telerik:RadTab
runat
=
"server"
Text
=
"Alternative Contacts"
PageViewID
=
"PageView1"
>
</
telerik:RadTab
>
<
telerik:RadTab
runat
=
"server"
Text
=
"Features/Facilities"
PageViewID
=
"PageView2"
Selected
=
"True"
>
</
telerik:RadTab
>
<
telerik:RadTab
runat
=
"server"
Text
=
"Gallery"
PageViewID
=
"PageView3"
>
</
telerik:RadTab
>
<
telerik:RadTab
runat
=
"server"
PageViewID
=
"PageView5"
Text
=
"Bookings"
>
</
telerik:RadTab
>
<
telerik:RadTab
runat
=
"server"
Text
=
"Statistics"
PageViewID
=
"PageView4"
>
</
telerik:RadTab
>
</
Tabs
>
</
telerik:RadTabStrip
>
<
telerik:RadMultiPage
runat
=
"server"
ID
=
"MultiPage1"
SelectedIndex
=
"0"
RenderSelectedPageOnly
=
"false"
Width
=
"656px"
>
<
telerik:RadPageView
runat
=
"server"
ID
=
"PageView1"
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text='<%# Eval("user_id") %>'></
asp:Label
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"AccommContactsGrid"
DataSourceID
=
"SqlDataSource6"
ShowFooter
=
"True"
AllowSorting
=
"True"
EnableLinqExpressions
=
"False"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
>
<
MasterTableView
ShowHeader
=
"true"
DataKeyNames
=
"accom_id"
PageSize
=
"7"
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
/>
<
CommandItemTemplate
>
<
div
style
=
"padding: 5px 5px;"
>
<
asp:LinkButton
ID
=
"btnInsertAccom"
CommandName
=
"InitInsert"
OnClientClick
=
"return ShowInsertForm();"
runat
=
"server"
><
img
style
=
"border: 0px; vertical-align:middle;"
src
=
"Images/03.png"
/>Add New Client Account</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"btnOptionsAccom"
CommandName
=
"Options"
runat
=
"server"
OnClientClick
=
"return ShowOptionsForm();"
><
img
style
=
"border: 0px; vertical-align:middle;"
src
=
"Images/09.png"
/>Options</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"btnRefreshAccom"
CommandName
=
"RebindGrid"
runat
=
"server"
><
img
style
=
"border: 0px; vertical-align:middle;"
src
=
"Images/21.png"
/>Refresh Link Group List</
asp:LinkButton
>
</
div
>
</
CommandItemTemplate
>
<
Columns
>
And so forth ...
Here's the codenehind.
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridNestedViewItem)
{
Panel panel = (Panel)e.Item.FindControl(
"InnerContainer"
);
if
(panel !=
null
)
{
panel.Visible = ((GridNestedViewItem)e.Item).ParentItem.Expanded;
}
}
}
The panel != null is there to obviously avoid failure but TBH it's pointless using the NestedViewTemplate if the codebehind isn't going to pick up the embedded control. It happens elsewhere in the code as well.