循环绑定数据的两个方法:
List<string> LIColl = new List<string>();
protected
void Page_Load(object sender, EventArgs e)
{
if
(!IsPostBack)
{
foreach (SPUser user in
web.AllUsers)//遍历所有用户
{
CheckBoxList1.Items.Add(user.Name);//直接绑定
LIColl.Add(user.Name);
//approversCollection.Add(new
SPFieldUserValue(web,user.ID,user.LoginName));
}
//CheckBoxList1.DataSource =
LIColl;//后续绑定
//CheckBoxList1.DataBind();//后续绑定
读取
private static string selval;//读取后放到里面去
protected void
CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
selval += CheckBoxList1.Items[i].Text + ";" +
selval;
}
}
}
CheckBoxList1复选框,布布扣,bubuko.com
原文:http://www.cnblogs.com/914556495wxkj/p/3630527.html