如何将一组数据绑定到checkedListBox控件里面
比如我有一组数据:
id  name
01  1年
02  2年
03  3年
00  所有这组数据不是从数据库取得,是直接在程序里面默认的,如何绑定到checkedListBox?

解决方案 »

  1.   

     System.Collections.Hashtable ht = new System.Collections.Hashtable();
     ht.Add("01", "1年");
     ht.Add("02", "2年");
     ht.Add("03", "3年");
      

  2.   

    1.代码实现:
          
                Hashtable ht = new Hashtable();
                ht.Add("01", "1年");ht.Add("02", "2年");
                ht.Add("03", "3年");ht.Add("00", "所有");
                this.CheckBoxList1.DataSource = ht;
                this.CheckBoxList1.DataTextField = "Value";
                this.CheckBoxList1.DataValueField = "Key";
                this.DataBind();2.手动实现 :
    点击控件右键属性,items 添加