CheckBoxList 设置选中的值 - CheckBoxListSetSelectedValue

2017-01-26 13:22:44  访问(2534) 赞(0) 踩(0)


        /// <summary>
        /// CheckBoxList 设置选中的值 - CheckBoxListSetSelectedValue
        /// </summary>
        /// <param name="chkl"></param>
        /// <param name="strValue"></param>
        public void CheckBoxListSetSelectedValue(CheckBoxList chkl, string strValue)
        {
            if (strValue == null || strValue.Length == 0)
            {
                CheckBoxListSetAllSelected(chkl, false);
                return;
            }

            strValue = strValue.Trim();

            if (strValue.Length == 0)
            {
                CheckBoxListSetAllSelected(chkl, false);
                return;
            }

            strValue = "," + strValue + ",";

            foreach (ListItem item in chkl.Items)
            {
                if (strValue.Contains("," + item.Value + ","))
                    item.Selected = true;
            }
        }


标签:CheckBoxList 设置选中的值 - CheckBoxListSetSelectedValue 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)