3 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 11 Aug 2008, 12:51 PM
Hi Ricky,
Try accessing the control in the ItemTemplate as shown below.
ASPX:
CS:
Regards
Princy.
Try accessing the control in the ItemTemplate as shown below.
ASPX:
<telerik:RadPanelBar ID="RadPanelBar1" runat="server" OnItemDataBound="RadPanelBar1_ItemDataBound" OnPreRender="RadPanelBar1_PreRender"> |
<ItemTemplate> |
<asp:Literal ID="Literal1" runat="server"></asp:Literal> |
</ItemTemplate> |
</telerik:RadPanelBar> |
CS:
protected void RadPanelBar1_PreRender(object sender, EventArgs e) |
{ |
foreach (RadPanelItem panelitem in RadPanelBar1.Items) |
{ |
Literal lit = (Literal)panelitem.FindControl("Literal1"); |
} |
} |
Regards
Princy.
0
Hello Ricky,
The FindControl method provides you with a reference to any control inside any of the templates used in the RadPanelBar or any of its PanelItems. You must make sure that you properly typecast the returned value as FindControl returns a reference to a Control class.
After you get the reference you may modify any properties of the referenced control. For details on the matter, please take a look at the following example - Accessing Nested Controls.
Best wishes,
Paul
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The FindControl method provides you with a reference to any control inside any of the templates used in the RadPanelBar or any of its PanelItems. You must make sure that you properly typecast the returned value as FindControl returns a reference to a Control class.
After you get the reference you may modify any properties of the referenced control. For details on the matter, please take a look at the following example - Accessing Nested Controls.
Best wishes,
Paul
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chase Florell
Top achievements
Rank 1
answered on 13 Aug 2008, 05:58 AM
EDIT >> SOLVED
Looks like you have to make sure that the Value="whatever" is in the right RadPanelItem... my bad
I have tried the info layed out in the example but I cannot figure out how to bind data to my grid which is nested inside a PanelBar.
Error I receive is:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Looks like you have to make sure that the Value="whatever" is in the right RadPanelItem... my bad
I have tried the info layed out in the example but I cannot figure out how to bind data to my grid which is nested inside a PanelBar.
'Get BizForSale By User data from Database |
Dim grdForSaleFind As RadGrid = DirectCast(RadPanelBar1.FindItemByValue("ForSaleAdmin").FindControl("grdBizForSaleAdmin"), RadGrid) |
Dim BizForSaleAdminDC As New DAL.BizForSaleDataContext |
Dim ForSaleAdminResults = BizForSaleAdminDC.bt_BizForSale_GetAll() |
grdForSaleFind.DataSource = ForSaleAdminResults |
grdForSaleFind.DataBind() |
'Get BizForSale By User data from Database |
Dim grdWantedFind As RadGrid = DirectCast(RadPanelBar1.FindItemByValue("WantedAdmin").FindControl("grdBizWantedAdmin"), RadGrid) |
Dim BizWantedAdminDC As New DAL.BizWantedDataContext |
Dim WantedAdminResults = BizWantedAdminDC.bt_BizWanted_GetAll() |
grdWantedFind.DataSource = WantedAdminResults |
grdWantedFind.DataBind() |
Error I receive is:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
|