RadComboBox.SelectedItem无法被赋值--它是只读的。

3

如果我的rad combobox在标记中设置了ReadOnly="false"属性,但我仍然收到错误消息,该如何设置它的值?

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

    if (dateArg != null)
    {
        rcbWeek.SelectedItem = rcbWeek.FindItemByText(dateArg);
    }
}
1个回答

4
以下是如何操作的步骤,您可以在Rad控件文档中找到它:

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;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接