Find RadComboBox in panelbar

3 posts, 1 answers
  1. Luis
    Luis avatar
    23 posts
    Member since:
    Mar 2009

    Posted 16 Sep 2009 Link to this post

    Greetings

    i have a RadPaneBar with a RadComboBox inside
    and want to fill the combobox at runtime
    for example:
         dim cmb as RadComboBox = ctype(RadPanelBar.parent.findcontrol("Comboname"),RadComboBox)
         dim a as integer
         for a = 1 to 30
            cmb.items.add(new RadComboBoxItem(a,a))
        next

    and gave me this error

    "Object reference not set to an instance of an object"


    please help
    thanks
    Luis
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Sep 2009 Link to this post

    Hi Luis,

    You could get the reference to corresponding PanelBarItem and then use the FindControl() method to access the RadComboBox as shown below:

    ASPX:
     
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server"
        <Items> 
            <telerik:RadPanelItem Text="Item1"
                <ItemTemplate> 
                    <telerik:RadComboBox runat="server" ID="Combo1"
                    </telerik:RadComboBox> 
                </ItemTemplate> 
            </telerik:RadPanelItem> 
             . . . 
        </Items> 
    </telerik:RadPanelBar> 

    CS:
     
    protected void Button1_Click(object sender, EventArgs e) 
        RadPanelItem panelItem = (RadPanelItem)RadPanelBar1.FindItemByText("Item1"); 
        RadComboBox combo = (RadComboBox)panelItem.FindControl("Combo1")

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Luis
    Luis avatar
    23 posts
    Member since:
    Mar 2009

    Posted 17 Sep 2009 Link to this post

    hi Shinu,

    the problem was, i have a panelItem inside another panelItem so when i try to find the comboBox i was searching in the first panel Item
    not in the second

    thanks a lot
Back to Top