关于弹出确认删除对话框的问题!!!
我在删除多条数据以前,先检查是否选定的有数据没?
如果有则弹出确认删除对话框。
如果没有则弹出请选择要删除的条目
代码如下:
protected void BtnDelect_Click(object sender, ImageClickEventArgs e)
{
//删除数据
System.Collections.Hashtable sqlHash = new System.Collections.Hashtable();
for (int i = 0; i <= this.GridView1.Rows.Count - 1; i++)
{
if (((CheckBox)this.GridView1.Rows[i].Cells[0].FindControl("CheckBox1")).Checked == true)
{
this.GridView1.DataKeyNames = new string[] { "ID" };
//获取选定的行的ID
int index = Convert.ToInt32(this.GridView1.DataKeys[i].Value.ToString());
string Del = "delete from [ASSETTYPE] where [ID] = '" + index + "'";
sqlHash.Add(Del,null);
}
}
if (sqlHash.Count > 0)
{
BtnDelect.Attributes.Add("onclick", "return confirm('确认要删除信息吗?');");??????
com.gameocean.SQLServerDAL.DbHelperSQL.ExecuteSqlTran(sqlHash);
GridView1.EditIndex = -1;
bind();
}
else
{
Response.Write("<script language=javascript>alert('请选择要删除的条目')</script>");
}
}
要怎么才能实现这个功能呢?