I'm usnig your RadCOmboBox on several of my pages. It is the same in all pages "Users" How can I make it so that the code behind is reused for the one dropdownlist? Also, how do I access the dropdown items in the events of the code behind like Button_OnClick ?
4 Answers, 1 is accepted
0
Hello George,
I suggest you place the RadComboBox in an User Control and use this user control where you need id.
As for accessing items you can use the Items property of RadComboBox . For example to access the first item you can use the following code:
C#
VB
More about RadComboBox you can find in our online help documentation.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I suggest you place the RadComboBox in an User Control and use this user control where you need id.
As for accessing items you can use the Items property of RadComboBox . For example to access the first item you can use the following code:
C#
string itemtext = RadComboBox1.Items[0].Text; |
VB
Dim itemtext As String = RadComboBox1.Items(0).Text |
More about RadComboBox you can find in our online help documentation.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 26 Aug 2008, 01:28 PM
I am using Q2 2008 ASP.NET AJAX and wondering why this error is happening when trying to access the dropdownlist
Compiler Error Message: CS1061: 'ASP.controls_dropdownlist_ascx' does not contain a definition for 'SelectedValue' and no extension method 'SelectedValue' accepting a first argument of type 'ASP.controls_dropdownlist_ascx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
This is also not working. :(
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.Compiler Error Message: CS1061: 'ASP.controls_dropdownlist_ascx' does not contain a definition for 'SelectedValue' and no extension method 'SelectedValue' accepting a first argument of type 'ASP.controls_dropdownlist_ascx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
|
This is also not working. :(
string itemtext = RadComboBox1.Items[0].Text; |
0
Hello George,
The reason for the error is the way you access the combobox. Please find the sample project which works as expected.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The reason for the error is the way you access the combobox. Please find the sample project which works as expected.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 26 Aug 2008, 03:16 PM
Rosi,
I don't want this in my page_load
I want to have it in the Search Method passing the arguments and it is always sending the default item even when I select something else in the dropdownlist. Is it because I am using AJAX ASP.NET ?
I don't want this in my page_load
protected void Page_Load(object sender, EventArgs e) |
{ |
RadComboBox combo1 = (RadComboBox)WebUserControl1.FindControl("RadComboBox1"); |
string itemText = combo1.Items[0].Text; |
Response.Write(itemText); |
} |
I want to have it in the Search Method passing the arguments and it is always sending the default item even when I select something else in the dropdownlist. Is it because I am using AJAX ASP.NET ?