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

Accessing RadGrid inside RadPanelBar

3 Answers 264 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Steve Humby
Top achievements
Rank 1
Steve Humby asked on 19 Mar 2009, 01:09 PM
Hi

I've had a look through the forum posts but haven't managed to find the solution. I want to populate my grid(s) inside the panelbar from the vb page (rather than using the DataSourceID) - I have used the following code in the Page_Load fuction to access the grid but I'm not sure how to bind the data to it:

Dim

 

StagesGrid As RadGrid = DirectCast(RadPanelBar1.FindItemByValue("PanelItem1").FindControl("RadGrid1"), RadGrid)

 

Dim

 

InvoicesGrid As RadGrid = DirectCast(RadPanelBar1.FindItemByValue("PanelItem2").FindControl("RadGrid2"), RadGrid)

Can you help? I usually populate data using the NeedDataSource function but it's not available in a nested control.

Many thanks in advance.

Steve :o)

3 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 19 Mar 2009, 02:32 PM
Hi Steve,

In general, your code works fine. Just make sure your are searching in the proper RadPanelItem, i.e.

ASPX:
<form id="form1" runat="server">  
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
</telerik:RadScriptManager> 
<telerik:RadPanelBar ID="RadPanelBar1" runat="server">  
    <Items> 
        <telerik:RadPanelItem runat="server" Text="Root RadPanelItem1">  
            <Items> 
                <telerik:RadPanelItem runat="server" Value="PanelItem1">  
                    <ItemTemplate> 
                        <telerik:RadGrid ID="RadGrid1" runat="server">  
                        </telerik:RadGrid> 
                    </ItemTemplate> 
                </telerik:RadPanelItem> 
            </Items> 
        </telerik:RadPanelItem> 
        <telerik:RadPanelItem runat="server" Text="Root RadPanelItem2">  
            <Items> 
                <telerik:RadPanelItem runat="server" Value="PanelItem2">  
                    <ItemTemplate> 
                        <telerik:RadGrid ID="RadGrid2" runat="server">  
                        </telerik:RadGrid> 
                    </ItemTemplate> 
                </telerik:RadPanelItem> 
            </Items> 
        </telerik:RadPanelItem> 
    </Items> 
</telerik:RadPanelBar> 
</form> 

Code-behind:
Imports Telerik.Web.UI  
 
Partial Class Default2  
    Inherits System.Web.UI.Page  
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
        Dim StagesGrid As RadGrid = DirectCast(RadPanelBar1.FindItemByValue("PanelItem1").FindControl("RadGrid1"), RadGrid)  
        Dim InvoicesGrid As RadGrid = DirectCast(RadPanelBar1.FindItemByValue("PanelItem2").FindControl("RadGrid2"), RadGrid)  
        Response.Write(StagesGrid.ID)  
        Response.Write(InvoicesGrid.ID)  
    End Sub 
End Class 
 


Kind regards,
Paul
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Steve Humby
Top achievements
Rank 1
answered on 19 Mar 2009, 02:59 PM
Hi Mark, thanks for the prompt reply.

Just realised after your reply that I've answered my own question... just had to fill a DataTable then assign it to the grids' DataSource property.... Doh!

Thanks again.

:o)
0
DK
Top achievements
Rank 2
answered on 15 Jul 2009, 06:50 AM
but hwen i put grid in the radpanel bar and when panel is expanding the nthe page is handed in IE7.
please resolve my query
Tags
PanelBar
Asked by
Steve Humby
Top achievements
Rank 1
Answers by
Paul
Telerik team
Steve Humby
Top achievements
Rank 1
DK
Top achievements
Rank 2
Share this question
or