CheckBoxList 获得选中的值 - CheckBoxListGetSelectedValue

2017-01-26 13:23:40  访问(2144) 赞(0) 踩(0)


        /// <summary>
        /// CheckBoxList 获得选中的值 - CheckBoxListGetSelectedValue
        /// </summary>
        /// <param name="chkl"></param>
        /// <returns></returns>
        public string CheckBoxListGetSelectedValue(CheckBoxList chkl)
        {
            StringBuilder theResult = new StringBuilder();
            bool isFirst = true;

            foreach (ListItem item in chkl.Items)
            {
                if (!item.Selected)
                    continue;

                if (isFirst)
                    isFirst = false;
                else
                    theResult.Append(",");

                theResult.Append(item.Value);
            }

            if (isFirst)
                return "";

            return theResult.ToString();
        }


标签:CheckBoxList 获得选中的值 - CheckBoxListGetSelectedValue 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)
 
  ┈全部┈  
 
(显示默认分类)