• checkboxlist控件的使用  


      /// <summary>
        /// 获取CheckBoxList复选框组中被选中的2.并生成0和1组成的字符串
        /// </summary>
        /// <param name="cblName">CheckBoxList的实例</param>
        /// <returns>返回一个0和1组成的字符串</returns>
        protected string getCheckBoxList(CheckBoxList cblName)
        {
            string strResult;
            foreach (ListItem li in cblName.Items)
            {
                if (li.Selected == true)
                {
                    strResult += 1;
                }
                else
                {
                    strResult += 0;
                }
            }
        }

        /// <summary>
        /// 根据0和1组成的字符串还原成checkboxlist选项值
        /// </summary>
        /// <param name="strCBL">数据库中的字符串</param>
        /// <param name="cblName">checkboxlist控件的实例</param>
        protected void setCheckBoxList(string strCBL, CheckBoxList cblName)
        {
            char[] charCBL = strCBL.ToCharArray();        //把字符串转换为字符数组
            for (int i = 0; i < cblName.Items.Count; i++)  //遍历复选框组
            {
                if(charCBL[i].Equals('1'))  //索引相同,如果字符的值为一,那么复选框选中
                {
                    cblName.Items[i].Selected=true; //选中复选框
                }
            }
        }
  • 相关阅读:
    Codeforces Round #336 B
    Codeforces Round #336 A
    hiho一下157
    Codeforces Round #420 E
    Codeforces Round #420 C
    Codeforces Round #420 B
    Codeforces Round #420 A
    Codeforces Round #418 C
    Codeforces Round #418 B
    CodeForces 811D Vladik and Favorite Game bfs,模拟
  • 原文地址:https://www.cnblogs.com/ly5201314/p/1385523.html
Copyright © 2020-2023  润新知