RadGrid Inside RadPanelBar (issues)

5 posts, 1 answers
  1. Mark
    Mark avatar
    25 posts
    Member since:
    Feb 2012

    Posted 16 Aug 2012 Link to this post

    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>

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 16 Aug 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark avatar
    25 posts
    Member since:
    Feb 2012

    Posted 17 Aug 2012 Link to this post

    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).
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Aug 2012 Link to this post

    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.
  6. Mark
    Mark avatar
    25 posts
    Member since:
    Feb 2012

    Posted 20 Aug 2012 Link to this post

    Hey, that worked... I don't get it.  But, I'll take it.

    Thanks! :-)
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017