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

[Solved] Dynamically creating ComboBox

1 Answer 142 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
chowbang
Top achievements
Rank 1
chowbang asked on 28 Apr 2008, 05:43 AM
Hi, I'm having a problem similar to the one described here: http://www.telerik.com/community/forums/thread/b311D-bcgkem.aspx. I'm creating a ComboBox dynamically, like below:

protected void Page_Load( object sender, EventArgs e )
{
  RadComboBox cb = new RadComboBox();
  cb.Items.Add( new RadComboBoxItem( "abc" ) );
  cb.Items.Add( new RadComboBoxItem( "def" ) );
  this.Controls.Add( cb );
}

Clicking the down arrow doesn't do anything. If I add the combobox to a Placeholder which is declaratively defined on the page, it works fine. Unfortunately, I can't have any declarative controls on the page.

I tried giving a unique ID as mentioned in that thread, but that didn't work (I've only got 1 combobox anyways). Any ideas?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 28 Apr 2008, 07:12 AM
Hello ,

I suggest you use this.Form.Controls.Add( cb ); instead of  this.Controls.Add( cb );

This should help.

Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
chowbang
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Share this question
or