This is a migrated thread and some comments may be shown as answers.

RadGrid Inside RadPanelBar (issues)

4 Answers 177 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 16 Aug 2012, 08:15 PM
Hi.  I have a page that contains a RadPanelBar - but within it, I'm trying to put in a RadGrid.  However, for whatever reason, the backend code doesn't recognize the grid inside the PanelBar (ItemTemplate).

Here is what I have.... Am I missing something?
<telerik:RadPanelBar ID="AccountPanels" runat="server" Width="100%" ExpandMode="FullExpandedItem">
    <Items>
        <telerik:RadPanelItem Text="Design History" runat="server" Expanded="True">
            <Items>
                <telerik:RadPanelItem runat="server" Value="OrderHistory">
                    <ItemTemplate>
                        <div style="height:350px; overflow-x:hidden; overflow-y:auto;">
                            <div style="width:97%;">
                                <div>
                                    <asp:Label ID="lblOpenItems" runat="server" Text="If you have any open unsaved items, they will show up in the grid below.  You can choose to edit, save and add to your cart.<br />Or you can choose to remove the item(s) permanently."></asp:Label><br /><br />
                                </div>
                                <asp:Panel ID="PnlOpenItems" runat="server">
                                    <telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server">
                                        <AjaxSettings>
                                            <telerik:AjaxSetting AjaxControlID="grdOpenItems">
                                                <UpdatedControls>
                                                    <telerik:AjaxUpdatedControl ControlID="grdOpenItems" />
                                                </UpdatedControls>
                                            </telerik:AjaxSetting>
                                        </AjaxSettings>
                                    </telerik:RadAjaxManagerProxy>
                                    <telerik:RadGrid ID="grdOpenItems" OnNeedDataSource="Item_NeedDataSource" OnItemDataBound="Item_ItemDataBound" runat="server" AutoGenerateColumns="false" AllowPaging="false">
                                        <ClientSettings>
                                            <Scrolling AllowScroll="True" ScrollHeight="150px" UseStaticHeaders="true" />
                                        </ClientSettings>
                                        <MasterTableView NoMasterRecordsText="You have no unsaved items at this time.">
                                            <Columns>
                                                <telerik:GridBoundColumn HeaderText="Customer ID" DataField="EntityContactNumber" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn HeaderText="Custom ID" DataField="CustomID">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn HeaderText="Item Number" DataField="ItemNumber">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn HeaderText="Template Name" DataField="FriendlyName">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn HeaderText="Date Created" DataField="DateAdded">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn HeaderText="DateModified" DataField="DateModified" Visible="False">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn HeaderText="CartId" DataField="CartId" Visible="False">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridButtonColumn UniqueName="btnEdit" HeaderText="Edit" DataTextField="ItemNumber">
                                                </telerik:GridButtonColumn>
                                                <telerik:GridButtonColumn UniqueName="btnDelete" HeaderText="Remove" DataTextField="CustomID">
                                                </telerik:GridButtonColumn>
                                            </Columns>
                                        </MasterTableView>
                                    </telerik:RadGrid>
                                </asp:Panel>
                            </div>
                        </div>
                    </ItemTemplate>
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelItem>
        <telerik:RadPanelItem Text="Previously Shipped Designs" Expanded="True" runat="server">
            <Items>
                <telerik:RadPanelItem runat="server" Value="MyProfile" Height="400px">
                    <ItemTemplate>
                        <telerik:RadAjaxPanel ID="ProfileAjax" runat="server">
                            <div style="height:350px;overflow-x:hidden;overflow-y:auto;">
                                <div style="width:97%;">
                                     
                                </div>
                            </div>
                            <asp:Panel ID="ProfileMessageHolder" runat="server" Visible="false" HorizontalAlign="Center">
                                <strong>Your profile has been saved</strong>
                            </asp:Panel>
                        </telerik:RadAjaxPanel>
                    </ItemTemplate>
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelItem>
    </Items>
</telerik:RadPanelBar>

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Aug 2012, 04:55 AM
Hi Mark,

I suppose you want to access the RadGrid in the CodeBehind which is inside the ItemTemplate of RadPanelBar. Try the following code snippet to access the RadGrid in serverside.

C#:
RadGrid grdOpenItems = (RadGrid)AccountPanels.FindItemByValue("OrderHistory").FindControl("grdOpenItems");

Hope this helps.

Regards,
Princy.
0
Mark
Top achievements
Rank 1
answered on 17 Aug 2012, 01:31 PM
It almost worked.  But the backend doesn't recognize the "AccountPanels" ID.
I tried this in two areas:
  • in the code as a public RadGrid

public RadGrid grdOpenItems = (RadGrid)AccounPanels.FindItemByValue("DesignHistory").FindControl("grdOpenItems");

  • in the code for the data source
RadGrid grdOpenItems = (RadGrid)AccounPanels.FindItemByValue("DesignHistory").FindControl("grdOpenItems");

neither of them recognize the "AccountPanels" (see attached image).
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Aug 2012, 04:38 AM
Hi Mark,

I was able to access the RadGrid in page load event. Please try accessing it as shown below.
C#:
protected void Page_Load(object sender, EventArgs e)
{
 RadGrid grdOpenItems = (RadGrid)AccountPanels.FindItemByValue("OrderHistory").FindControl("grdOpenItems");
}

Thanks.
Princy.
0
Mark
Top achievements
Rank 1
answered on 20 Aug 2012, 01:53 PM
Hey, that worked... I don't get it.  But, I'll take it.

Thanks! :-)
Tags
PanelBar
Asked by
Mark
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Share this question
or