获取checkboxlist选中的值以及绑定来自之前选中的来自数据库的值

            
///
///ps:一下几句都是一个意思,为的是以后有人搜索关键字的时候能定位到这里
///checkboxlist绑定选中值
///checkboxlist绑定来之mssql数据的值
///checkboxlist绑定来自之前选中的值
///checkboxlist绑定编辑选中值
string strapp = "1,2,3"

string[] strtemp = strapps.Split(','); foreach (string str in strtemp) { for (int i = 0; i < CheckBoxList1.Items.Count; i++) { if (this.CheckBoxList1.Items[i].Value == str) { this.CheckBoxList1.Items[i].Selected = true; } } }

获取选中checkboxlist选中的值

           string funtext = string.Empty;
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected == true)
                {
                    funtext += CheckBoxList1.Items[i].Value + ",";

                }
            }

 转载请注明来源wikizhao

posted @ 2013-11-19 17:37  WikiZhao  阅读(524)  评论(1编辑  收藏  举报
Copyright©2013-2014 WikiZhao