62,041
社区成员
发帖
与我相关
我的任务
分享
public void bind()
{
DataTable ds = DB.GetDataTable("select * from 表");
this.GridView1.DataSource = ds;
this.GridView1.DataKeyNames = new string[] { "ID" };
this.GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
StringBuilder sb =new StringBuilder();
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (cbox.Checked == true)
{
sb.Append(GridView1.DataKeys[i].Value+",");
}
}
DataTable ds = DB.GetDataTable("select 字段 from 表 where ID in (" +sb.ToString().TrimEnd(',') +")");
this.GridView2.DataSource = ds;
this.GridView2.DataBind();
}