Add RadGrid to RadPanelItem Dynamically via c#

2 posts, 0 answers
  1. Robert
    Robert avatar
    1 posts
    Member since:
    May 2011

    Posted 03 May 2011 Link to this post

    I am creating a RadGrid dynamically based on data that comes through.  The number of grids can vary.  What I want to do is allow for the collapsing of these grids.  For example, if 10 grids are created, the length is unwieldy and I would like to collapse all but the first, and have the user be able to expand them on click.  I have looked around and do not see a solution within the grid itself.  I would like to keep the header row as the column names, and use something above it sort of detailing the grid like "Number of Customers: #".

    My theoretical solution was to use a RadPanelBar, inserting the grid into a RadPanelItem, and then into the PanelBar.  Looking at the demo of the calendar shows:

    <telerik:RadPanelBar  runat="server" ID="RadPanelBar1" Height="380px" ExpandMode="FullExpandedItem">
                <Items>
                    <telerik:RadPanelItem Text="Calendar" ImageUrl="Img/calendar.gif">
                        <Items>
                            <telerik:RadPanelItem>
                                <ItemTemplate>
                                    <telerik:RadCalendar runat="server" ID="Calendar1" Style="margin: 6px auto 0" />
                                </ItemTemplate>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelItem>
                 </Items>
    </telerik:RadPanelBar>

    However, I am required to create this from the codebehind.  I've gone through quite a few iterations and can't seem to find the syntax.  I am guessing it has to do with ItemTemplate.InstantiateIn(grid), but do I have to extend the ITemplate or something?
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 09 May 2011 Link to this post

    Hello Robert,

    On how to add templates dynamically from code behind, please refer to the following help article.

    Best wishes,
    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top