取值代码
代码
for (int i = 0; i < CheckBoxList1.Items.Count; i++) {
if (CheckBoxList1.Items[i].Selected == true) {
if (checkid != string.Empty)
checkid += "," + CheckBoxList1.Items[i].Value; else
checkid += CheckBoxList1.Items[i].Value;
}
}
修改的时候默认值的代码
代码
if (Info.CourseId != string.Empty)
{
string[] str = Info.CourseId.Split(new char[] { ',' });
foreach (string strinfo in str)
{
ListItem NewItem = (ListItem)CheckBoxList1.Items.FindByValue(strinfo);
if (NewItem != null)
NewItem.Selected = true;
}
}