我有一个CheckBoxList,有属性值若干...想请教如何设定多个默认的初始值。例如:
待选答案:A,B,C,D,E,F我想默认选中的: A,D,E
用CheckBoxList.SelectedValue似乎只能设置一个默认选项。

解决方案 »

  1.   

    看看是否符合要求。
    this.checkedListBox1.SetItemChecked(0,true);
    this.checkedListBox1.SetItemChecked(3,true);
    this.checkedListBox1.SetItemChecked(5,true);
      

  2.   

    静态选项可以直接在页面上写
    <asp:ListItem Value="1" Selected="True">1</asp:ListItem>
      

  3.   

    我是动态的..to: loveZHYforEver(只爱陌生人) 谢谢你的方法。因为是动态的,只知道几个值,并不知道每个对应的索引是哪个,所以这样似乎不太完美..
      

  4.   

    做个for循环for (int i = 0;i < this.checkbox.items.count;i++)
    {
        if (this.checkbox.items[i].value == 你的value)
        {
            this.checkbox.items.Selected = true;
        }
    }