GridView中双主键如何一次删除多条记录 RT,GridView中有双主键如何一次删除多条记录. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 问题描述不清楚 什么时候GridView也有主键这种说法了 描述不清删除多个可 in (ID号) GridView1.Rows[index].DataKeys.Values[0].ToString(); GridView1.Rows[index].DataKeys.Values[1].ToString(); 其他删除一样操作 例如Delete A_ATTENDACNE_D WHERE STAFF_CODE='0001' AND ATT_DATE='2012-07-01'gridview中第一列是staff_code,第二列是att_date,Gridview中选择多条后如何实现批量删除。 一条一条执行SQL语句没有问题,能否只执行一条SQL语句 加checkbox,选中的就删除。代码如下:protected void btnDelAll_Click(object sender, EventArgs e) { string ids = string.Empty; foreach (GridViewRow gr in this.gvList.Rows) { CheckBox cb = gr.FindControl("chkID") as CheckBox; if (cb.Checked) ids += this.gvList.DataKeys[gr.RowIndex].Value + ","; } if (!string.IsNullOrEmpty(ids)) { if (!new ArticleManager().DeleteArticles(ids.Substring(0, ids.Length - 1))) Page.ClientScript.RegisterStartupScript(GetType(), "success", "<script>alert('删除失败,请重试!');</script>"); else { this.gvList.DataSource = new ArticleManager().GetArticles(); this.gvList.DataBind(); } }} 邮件群发 asp.net做的网页打不开 【急】一个关于写入txt文件的问题 自动生成编号根据日期+当前存在的条数 求一文本编辑器控件 关于Web引用问题 请问下不利用datagrid摸版,自己写个连接列,请问怎么写?有例子吗?马上结贴 疑难杂病:asp.net Sql Server 2005 无法插入数据 谁有xp风格的下拉菜单样式css或者源代码,请给小弟一份,谢谢 ASP.NET中怎么用程序得到本页面的文件名称? 求救!SOS 在退出主页打开登录页面后,如何在退出时就刷新登陆页面
删除多个可 in (ID号)
GridView1.Rows[index].DataKeys.Values[1].ToString();
其他删除一样操作
gridview中第一列是staff_code,第二列是att_date,Gridview中选择多条后如何实现批量删除。
代码如下:protected void btnDelAll_Click(object sender, EventArgs e)
{
string ids = string.Empty;
foreach (GridViewRow gr in this.gvList.Rows)
{
CheckBox cb = gr.FindControl("chkID") as CheckBox;
if (cb.Checked)
ids += this.gvList.DataKeys[gr.RowIndex].Value + ",";
}
if (!string.IsNullOrEmpty(ids))
{
if (!new ArticleManager().DeleteArticles(ids.Substring(0, ids.Length - 1)))
Page.ClientScript.RegisterStartupScript(GetType(), "success", "<script>alert('删除失败,请重试!');</script>");
else
{
this.gvList.DataSource = new ArticleManager().GetArticles();
this.gvList.DataBind();
}
}
}