Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RadComboBox.SelectedItem cannot be assigned to -- it is read only

How can I set the value of my rad combobox if I keep getting this error message, even if the combobox has the ReadOnly="false" attribute set in the markup?

protected void Page_Init(object sender, EventArgs e)
{
    string dateArg = Request.QueryString["date"];

    if (dateArg != null)
    {
        rcbWeek.SelectedItem = rcbWeek.FindItemByText(dateArg);
    }
}
like image 238
JF Beaulieu Avatar asked Dec 06 '25 05:12

JF Beaulieu


1 Answers

Here is how to do it, you can find it in the docs for the Rad Controls:

http://www.telerik.com/help/aspnet-ajax/combobox-items-server-side-code.html

//Use RadComboBoxItem.Selected
RadComboBoxItem item = RadComboBox1.FindItemByText("Item 2");
item.Selected = true;

//Use RadComboBox.SelectedIndex
int index = RadComboBox1.FindItemIndexByValue("2");
RadComboBox1.SelectedIndex = index;

//You can also use the SelectedValue property.
RadComboBox1.SelectedValue = value;
like image 155
Stefan H Avatar answered Dec 07 '25 18:12

Stefan H



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!