Telerik
Skip Navigation LinksHome / Community / Forums / ASP.NET > Panelbar > If I place any .Net server control on “Rad Panel Bar”, how to access / find those controls on code behind files

Not answered If I place any .Net server control on “Rad Panel Bar”, how to access / find those controls on code behind files

Feed from this thread
  • shaik avatar

    Posted on Dec 25, 2007 (permalink)

        
     
    If we place any.Net Server control with in the  “Rad Panel Bar”, we can not access those controls in code behind files.

    For example i have asp.net 2.0 textbox,button controls in RAD Panel Bar.

    If we want to add any functionality in  button_click event in code behind file,

    we can not access the button on server side (code behind files like sample.aspx.cs or sample.aspx.vb ).

    Reply

  • Telerik Admin admin's avatar

    Posted on Dec 27, 2007 (permalink)

    Hi shaik,

    The FindControl method provides you with a reference to any control inside any of the templates user 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. Please refer to our Accessing Nested Controls online example for details on the matter. In the code tabs below the example you can find the code used.

    Kind regards,
    Paul
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Erdman avatar

    Posted on Jan 22, 2009 (permalink)

    Do you have an example that accesses a RadGrid control? Particularily I need access to the displaylayout so that I can include customer validation.

    Reply

  • Stephen avatar

    Posted on Nov 12, 2009 (permalink)

    Hello,

    This may be a simple question but it is related.  I know how to access the regular controls within the RadPanelBar as described in the documentation:

      
    Dim
    txtEmail As TextBox = CType(RadPanelBar1.FindControl("txtEmail"), TextBox)

    But how do I access another Rad Control from within the RadControlPanel?  For instance I am using the RadDatePicker, but I don't know what the Type definition is.  I tried RadDatePicker but that is not recognized by Visual Studio.  Do I need to Import something in my Class in order to get these references?

    Dim radArrivalDate As RadDatePicker = CType(RadPanelBar1.FindControl("radArrivalDate"), RadDatePicker)

    Thanks,

    Steve

     

     

    Reply

  • Shinu MVP Shinu's avatar

    Posted on Nov 18, 2009 (permalink)

    Hello Steve,

    Have you added the Telerik namespace reference to the page? The defenition of RadDatePicker class is coming under the namespace Telerik.Web.UI. So it will complile only if you add the namespace Telerik.Web.UI. Try it and see whether it is working.

        Imports Telerik.Web.UI

    [Note: If you are using ASP.NET version (not the Ajax version), then add Telerik.WebControls namespace reference instead of Telerik.Web.Ui.]

    Regards,
    Shinu.

    Reply

  • Stephen avatar

    Posted on Nov 19, 2009 (permalink)

    That did it thanks.  I wasn't importing the full namespace, I only had Imports Telerik.  Thanks!

    Reply

  • Stephen avatar

    Posted on Nov 23, 2009 (permalink)

    Hello again,

    I am having another similar problem.  I have a DropDownList control on the page in a RadPanelBar and I am trying to build the DDL in the code behind on the Page_Load but I get the "Object reference not set to an instance of an object." error.

    Here is my code:

     

     

            If Not IsPostBack Then  
                Dim ds As DataSet = cCountries.dsCountryList(sUserID)  
                Dim vw As DataView = New DataView(ds.Tables(0))  
                Dim i As Integer = 0 
                Dim lstCountry As DropDownList = CType(RadPanelBar1.FindControl("lstCountry"), DropDownList)  
                lstCountry.Items.Insert(i, New ListItem("(Select One)", ""))  
                For Each row As DataRowView In vw  
                    i = i + 1  
                    Dim sID As String = row("CountryID").ToString  
                    Dim sDescription As String = row("Description").ToString  
                    lstCountry.Items.Insert(i, New ListItem(sDescription, sID))  
                Next  
            End If 


    The error is thrown when it hits the Items.Insert.  I am already referencing the DDL using FindControl so I'm not sure what else I need to do.  On a similar page that does not have the RadPanelBar I am able to build my DDL this way.

    Thanks,

    Steve

     

    Reply

  • Telerik Admin admin's avatar

    Posted on Nov 24, 2009 (permalink)

    Hello Stephen,

    You should point the item that holds the templated control, i.e.

    If Not IsPostBack Then 
                Dim ds As DataSet = cCountries.dsCountryList(sUserID) 
                Dim vw As DataView = New DataView(ds.Tables(0)) 
                Dim i As Integer = 0
                Dim lstCountry As DropDownList = CType(RadPanelBar1.FindItemByValue("templateHolder").FindControl("lstCountry"), DropDownList) 
                lstCountry.Items.Insert(i, New ListItem("(Select One)", "")) 
                For Each row As DataRowView In vw 
                    i = i + 1 
                    Dim sID As String = row("CountryID").ToString 
                    Dim sDescription As String = row("Description").ToString 
                    lstCountry.Items.Insert(i, New ListItem(sDescription, sID)) 
                Next 
            End If


    Kind regards,
    Paul
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Stephen avatar

    Posted on Nov 24, 2009 (permalink)

    Hello,

    Thank you again for the quick reply.  That did it for me.

    thanks,

    Steve

    Reply

Back to Top

Skip Navigation LinksHome / Community / Forums / ASP.NET > Panelbar > If I place any .Net server control on “Rad Panel Bar”, how to access / find those controls on code behind files

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.