在asp中如何用一个button删除多条勾选的记录(gridview中的)?
请各位大侠给出cs中的代码,谢谢 --------------------编程问答-------------------- 循环逐条删除???等待高手答案..... --------------------编程问答-------------------- 逐条删肯定不如用in子句删... 不过我也不会-_- --------------------编程问答-------------------- string del = "";
把勾选的数据全扔进 del 里。然后
delete from 表 Where id in ("+del+")
--------------------编程问答-------------------- LZ,给你看看我的cs代码:
//删除选中按钮事件
protected void deleteSelectedBtn_Click(object sender, EventArgs e)
{
int intFlag=0;
for (int i = 0; i < this.ShowMailGridView.Rows.Count; i++)
{
GridViewRow row = this.ShowMailGridView.Rows[i];
HtmlInputCheckBox selectedChkbox=(HtmlInputCheckBox)row.FindControl("selectedchkbox") as System.Web.UI.HtmlControls.HtmlInputCheckBox;
if (selectedChkbox !=null && selectedChkbox.Checked)
{
int InfoId = Convert.ToInt32(selectedChkbox.Value);
intFlag = Mail.DeleteMail(InfoId);
}
}
if (intFlag > 0)
{
thisShowMailGridViewDataBind();
}
}
//删除全部按钮事件
protected void deleteAllBtn_Click(object sender, EventArgs e)
{
int intFlag = 0;
for (int i = 0; i < this.ShowMailGridView.Rows.Count; i++)
{
GridViewRow row = this.ShowMailGridView.Rows[i];
HtmlInputCheckBox selectedChkbox=(HtmlInputCheckBox)row.FindControl("selectedchkbox") as System.Web.UI.HtmlControls.HtmlInputCheckBox;
if(selectedChkbox !=null)
{
int InfoId = Convert.ToInt32(selectedChkbox.Value);
intFlag = Mail.DeleteMail(InfoId);
}
}
if (intFlag > 0)
{
thisShowMailGridViewDataBind();
}
} --------------------编程问答-------------------- HTML,gridview中的ItemTemplate代码
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%" >
<tr align="left" style="font-weight:normal;font-size:9pt" valign="middle">
<td width="4%" align="center">
<input type="checkbox" id="selectedchkbox" value='<%#DataBinder.Eval(Container.DataItem,"InfoID") %>' runat="server" /></td>
<td width="4%" align="center> </td>
<td align="left" valign="middle" width="35%">
<a href="LookMail.aspx?MailId=<%#DataBinder.Eval(Container.DataItem,"MailID")%>" target="_self"><font color="#9933ff"><%DataBinder.Eval(Container.DataItem, "Subject")%></font></a>
</td>
<td align="center" valign="middle" width="15%">
<%#DataBinder.Eval(Container.DataItem,"UserID") %>
</td>
<td align="center" valign="middle" width="15%">
<%=ReceiversNamelbstring%>
</td>
<td align="center" valign="middle" width="15%">
<%#DataBinder.Eval(Container.DataItem, "SendDate", "{0:yyyy-MM-dd HH:mm}")%>
</td>
<td align="center" valign="middle" width="12%">
</td>
</tr>
</table>
</ItemTemplate> --------------------编程问答-------------------- 谢谢各位,尤其是风车车,那么详细,偶也是四川的哈~~ --------------------编程问答--------------------
补充:.NET技术 , C#