您的位置首页生活小窍门

C#中checklistbox的用法

C#中checklistbox的用法

前台: 后台: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindCKBoxList(); } } static SqlConnection conn = new SqlConnection(@"server=;database=;uid=;pwd=;"渗侍裂); private void BindCKBoxList() { SqlDataAdapter dapt = new SqlDataAdapter(@"select * from item",conn); DataTable dt = new DataTable(); dapt.Fill(dt); CheckBoxList1.DataTextField = "name";/丛闭/项目名称 CheckBoxList1.DataValueField = "id";//项目编号 CheckBoxList1.DataSource = dt; CheckBoxList1.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { SqlCommand comm=new SqlCommand(); comm.Connection = conn; SqlParameter[] sp={new SqlParameter("@itemid",SqlDbType.Int), new SqlParameter("@staffid",SqlDbType.VarChar)}; conn.Open(); for (int i=0;i