如何在checkboxList后面加横线 输入的东西存在表中
展开全部
table1和table2都有两个字段ID,data。
以下代码是将table1绑定到CheckBoxList控件里。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.CheckBoxListBind();
}
}
public void CheckBoxListBind()
{
SqlConnection con = DB.creatconnection();
con.Open();
SqlCommand cmd = new SqlCommand("select * from table1", con);
this.CheckBoxList1.DataTextField = "data";
this.CheckBoxList1.DataValueField = "ID";
this.CheckBoxList1.DataSource = cmd.ExecuteReader();
this.CheckBoxList1.DataBind();
}
以下代码是将table1绑定到CheckBoxList控件里。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.CheckBoxListBind();
}
}
public void CheckBoxListBind()
{
SqlConnection con = DB.creatconnection();
con.Open();
SqlCommand cmd = new SqlCommand("select * from table1", con);
this.CheckBoxList1.DataTextField = "data";
this.CheckBoxList1.DataValueField = "ID";
this.CheckBoxList1.DataSource = cmd.ExecuteReader();
this.CheckBoxList1.DataBind();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询