日期:2014-05-18 浏览次数:20345 次
<script language="javascript" type="text/javascript"> function CheckForm(obj) { var i; var intListLength; intListLength = obj.chk.length; for(i=1; i < intListLength; i++) { if(obj.chk[i].checked) { if(window.confirm("您确认需要删除操作吗?")) { return true; } else { return false; } } } return false; } </script>
String SQL; SQL = "select * from [order]"; SqlDataAdapter sda = new SqlDataAdapter(SQL, conn); DataSet ds = new DataSet(); sda.Fill(ds, "[order]"); DataTable dt = ds.Tables["[order]"]; int i = 0; foreach (DataRow row in dt.Rows) //输出html表格 { Label1.Text += "<table><tr><td><input type='checkbox' id=chk" + i + " name='chk' value=" + row["id"].ToString() + " runat='server'/></td><td>" + (row["sn"]) + "</td></tr></table>"; i++; }
protected void Button5_Click(object sender, EventArgs e) { DefaultPage(); conn.Open(); string SQL; SQL = "select * from [order]"; SqlDataAdapter sda = new SqlDataAdapter(SQL,conn); DataSet ds = new DataSet(); sda.Fill(ds, "[order]"); DataTable dt = ds.Tables["order"]; for (int i = 0; i < dt.Rows.Count; i++) //一运行到这里就提示未将对象引用设置到对象的实例。 { System.Web.UI.HtmlControls.HtmlInputCheckBox chk = (System.Web.UI.HtmlControls.HtmlInputCheckBox)this.FindControl("chk" + i); if (chk.Checked) { Response.Write(chk.Value); } } conn.Close(); }