This is a migrated thread and some comments may be shown as answers.
Find RadComboBox in panelbar
2 Answers 41 Views
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 16 Sep 2009, 02:03 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 17 Sep 2009, 04:25 AM
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.
0
Luis
Top achievements
Rank 1
answered on 17 Sep 2009, 12:23 PM
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
Asked by
Luis
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Luis
Top achievements
Rank 1
Share this question
or