RadComboBox.SelectedItem无法分配 - 它是只读的

时间:2012-03-12 21:39:34

标签: c# asp.net telerik

如果我不断收到此错误消息,即使组合框在标记中设置了ReadOnly="false"属性,如何设置我的组合框的值?

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

    if (dateArg != null)
    {
        rcbWeek.SelectedItem = rcbWeek.FindItemByText(dateArg);
    }
}

1 个答案:

答案 0 :(得分:4)

以下是如何操作,您可以在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;