一、aspx中
<asp:CheckBoxList runat="server" ID="chklstOrgs" TextAlign="Left" Width="347px"></asp:CheckBoxList>
二、绑定数据 cs
方法一:
/// <summary>
/// chklstOrgs绑定组织机构信息
/// </summary>
public void bindChklstOrgs()
{
KS_ORGBLL orgBll = new KS_ORGBLL();
IList<KS_ORG> orgs = orgBll.GetAllOrg();
this.chklstOrgs.DataSource = orgs;
this.chklstOrgs.DataTextField = "OrgName";
this.chklstOrgs.DataValueField = "OrgCode";
this.DataBind();
}
方法二:
//public void BindChklstClasses()
//{
// IList<PubClassInfo> lstClass = transcate.GetClassList();
// foreach (PubClassInfo cls in lstClass)
// {
// ListItem item = new ListItem();
// item.Text = cls.ClassCName;
// item.Value = cls.ClassID;
// chklstClass.Items.Add(item);
// }
//}
三、使用数据cs
for (int i = 0; i < this.chklstOrgs.Items.Count; i++)
{
if (chklstOrgs.Items[i].Selected == true)
{
ou.OrgCode = chklstOrgs.Items[i].Value;
ou.UserID = userAdd.UserID;
ouBll.AddUserOrg(ou);
}
}