protected void btn_Ok_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cka = (CheckBox)GridView1.Rows[i].FindControl("chkid");
if (cka.Checked)
{ int id = Convert.ToInt32(GridView1.DataKeys[i].Value.ToString()); string strsql = "delete from orders where id='" + id + "'"; string strsql123 = "select pdfPath from orders where id ='" +id+ "'";
DataRow drw = DBFun.GetDataRow(strsql123);
string filename = drw["pdfPath"].ToString();
if (Directory.Exists(filename) == false)
{
if (DBFun.ExecuteUpdate(strsql))
{
ltl_Msg.Text = "删除成功!";
DataView dvlist = DBFun.GetDataView("select * From orders order by id desc");
AspNetPager1.RecordCount = dvlist.Table.Rows.Count;
Session["dvlist"] = dvlist;
bindData();
}
}
else
{ string path = Server.MapPath("..//uploadpic//" + filename);
System.IO.File.Delete(path);
if (DBFun.ExecuteUpdate(strsql))
{
ltl_Msg.Text = "删除成功!";
DataView dvlist = DBFun.GetDataView("select * From orders order by id desc");
AspNetPager1.RecordCount = dvlist.Table.Rows.Count;
Session["dvlist"] = dvlist;
bindData();
}
}
} } }
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cka = (CheckBox)GridView1.Rows[i].FindControl("chkid");
if (cka.Checked)
{ int id = Convert.ToInt32(GridView1.DataKeys[i].Value.ToString()); string strsql = "delete from orders where id='" + id + "'"; string strsql123 = "select pdfPath from orders where id ='" +id+ "'";
DataRow drw = DBFun.GetDataRow(strsql123);
string filename = drw["pdfPath"].ToString();
if (Directory.Exists(filename) == false)
{
if (DBFun.ExecuteUpdate(strsql))
{
ltl_Msg.Text = "删除成功!";
DataView dvlist = DBFun.GetDataView("select * From orders order by id desc");
AspNetPager1.RecordCount = dvlist.Table.Rows.Count;
Session["dvlist"] = dvlist;
bindData();
}
}
else
{ string path = Server.MapPath("..//uploadpic//" + filename);
System.IO.File.Delete(path);
if (DBFun.ExecuteUpdate(strsql))
{
ltl_Msg.Text = "删除成功!";
DataView dvlist = DBFun.GetDataView("select * From orders order by id desc");
AspNetPager1.RecordCount = dvlist.Table.Rows.Count;
Session["dvlist"] = dvlist;
bindData();
}
}
} } }
解决方案 »
- 已经重写了类的GetHashCode()和Equals(),为什么做字典的键时依然无效?
- 两个动态数组如何相加到一起
- 关于xpath查询的问题
- 高手帮忙啊~~~~Socket和TcpListener在接收数据时,为什么总接收不完??
- C#里面还存在函数是把一个数值转成高八位和低八位的啊?
- 请教C#导入导出Excel的问题(外部表不是预期的格式?)
- 如何设置DataGridView的一个指定的单元格为编辑状态(顺便散分)
- socket编程
- 请问在c#中判断汉字的正则表达式是什么?
- HTTP请求乱码问题
- c# winform 一个关于textbox输入的问题
- DevExpress的LayoutControl中控件的排版
你现在没删除一个就绑定一下,这要是选择多了性能很差
后端不用循环就只管 "delect xxx where id in (" +request["name"]+")" 一句就ok了