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

Adding a RadGrid (Or Any Control) to ComboBox at Runtime

3 Answers 61 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 22 Oct 2008, 08:41 PM
How do I go about adding a RadGrid to a RadComboBox at runtime in order to make a multi-column dropdown similar to the one sampled here:http://demos.telerik.com/ASPNET/Prometheus/Combobox/Examples/Functionality/Templates/DefaultCS.aspx (the Initiator).

I've created custom Templates before, but I'm having trouble figuring out what steps are necessary in the situation. Among other things I've tried the following:

DataTable table; 
 
table = //Set the table via a sql query. 
 
RadGrid grid = new RadGrid(); 
        
grid.DataSource = table; 
grid.DataBind(); 
 
RadComboBoxItem item = new RadComboBoxItem(); 
item.Controls.Add(grid); 
 
combo.Items.Add(item); 

Thanks.

3 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 23 Oct 2008, 09:59 AM
Hi Andrew,

I think the code that you paste should works as expected.

You can also follow our article Adding templates at runtime

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Andrew
Top achievements
Rank 1
answered on 23 Oct 2008, 11:55 AM
Unfortunately it does not work. I'm am currently getting this error when I add the RadGrid to the RadComboBoxItem and bind the RadComboBox:

"Script control '' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptcontrol"

Any idea what this means?
0
Rosi
Telerik team
answered on 24 Oct 2008, 11:43 AM
Hello Andrew,

This problem occurs if RadComboBox populates its items by using the LoadOnDemand feature.Then the items are loaded during callback. RadGrid registers its scripts in the Pre_Render event  which is not executed during callback. This causes the issue. However this cannot be overridden. I suggest you do not use LoadOnDemand in this case.

Kind regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Andrew
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or