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

[Solved] Programmatically creating related RadComboBoxes

4 Answers 258 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 05 Jun 2009, 04:21 PM
Hi,

What I'm trying to do is programatically create anywhere from 5-15 comboboxes on a page (number will vary based on user information).  While this part is easy enough, I also have need to make them related.  If I were dropping the control on the page, I'd be using the OnItemsRequested method, but since I'm doing this programmatically and the method is Protected, I'm stuck.

Here's what I've attempted:

 
Dim cmbo As New RadComboBox
cmbo.ID = "cmboTest"
cmbo.OnClientItemsRequested = "" 'Telerik.Web.UI.RadComboBox.Protected Overrideable Sub OnItemsRequested(...) is not accessible in this context because it is Protected.
cmbo.EnableLoadOnDemand = True  
cmbo.DataSource = GetValues("Test")
cmbo.DataBind()

 

4 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 09 Jun 2009, 11:56 AM
Hello Eric,

You should subscribe to ItemsRequested event like this:

Dim cmbo As New RadComboBox()  
cmbo.ID = "cmboTest" 
AddHandler cmbo.ItemsRequested, AddressOf cmbo_ItemsRequested 

and the event handler:

Protected Sub cmbo_ItemsRequested(ByVal sender As ObjectByVal e As RadComboBoxItemsRequestedEventArgs)  
 
End Sub 

Regards,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Shimon
Top achievements
Rank 1
answered on 08 Jul 2009, 08:22 PM
Hi,

How i can accomplish the same thing with c#?
I haven't seen any examples to addhandler to radcombobox dynamically.

Appreciate your help.

Shimon
0
Princy
Top achievements
Rank 2
answered on 14 Jul 2009, 01:20 PM
Hi,

You could use the following code snippet in order to add handler dynamically.

C#:
 
RadComboBox radcombobox = mew RadComboBox();  
radcombobox.ID= "RadCombo";  
radcombobox.ItemsRequested+=new RadComboBoxItemsRequestedEventHandler(radcombobox_ItemsRequested); 

And here is the event handler.
 
void radcombobox_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)  
{  
    //Your code goes here  
You can also use the following link in order to convert VB code to C# and vice versa.
Code Converter

Thanks,
Princy.
0
Rajesh Meenrajan
Top achievements
Rank 1
answered on 19 Aug 2009, 09:03 PM
This does not work as you said atleast in sharepoint. I get Javascript error for using the RadComboBox.

Here is the error:

'addEventListner' is null or not an object

 
Found this problem in version: 2009.2.701.0

Thank you,
Raj

Tags
ComboBox
Asked by
Eric
Top achievements
Rank 1
Answers by
Yana
Telerik team
Shimon
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Rajesh Meenrajan
Top achievements
Rank 1
Share this question
or