我在一个DropDownList里绑定了所有管理员的名字,各自的权限字段已经提取出来了,我是以逗号分割的。下面是一个CheckBoxList,里面全部是全部的权限名称,怎么通过选择不同的管理员,CheckBoxList里面的对应的权限名的Selected=true?

解决方案 »

  1.   

    在DropDownList的改变选项事件中foreach(ListItem item in CheckBoxList1.Items)
        item.Selected=false;
    CheckBoxList1.Items[DropDownList1.SelectedIndex].Selected = true;注意要设置下拉框的AutoPostBack=true,否则服务器事件不起作用。
      

  2.   

            string str = 提取的权限字段;
            string[] ss = str.Split(",".ToCharArray());
            foreach (string i in ss)
            {
                foreach (CheckBoxList it in ···)
                {
                    if (i == it.Text)
                    {                }
                }
    如果这样写,有没有办法实现啊??
      

  3.   

    参考:
    http://www.cnblogs.com/insus/archive/2011/06/17/2081639.html