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

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

string[] strtemp = strapps.Split(',');
foreach (string str in strtemp)
{
for (int i = ; 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 = ; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected == true)
{
funtext += CheckBoxList1.Items[i].Value + ","; }
}

转载请注明来源wikizhao