求大神指教 我这里面的删除不好用 怎么改呢
using System;using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Datas_index_dw : System.Web.UI.Page
{
DataBase db = new DataBase();
String sql = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["ano"] == null)
{
Response.Write("<script> javascript:alert('请先登录!'); </script>");
Response.Redirect("../login.aspx");
}
else
{
sql = "select * from dw";
getdata(sql);
}
}
}
private void getdata(string sql)
{
DataSet result = db.Getdata(sql);
if (result != null)
{
if (result.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = result.Tables[0];
GridView1.DataKeyNames = new string[] { "dno" };
GridView1.DataBind();
}
else
{
Response.Write("<script> javascript:alert('没有相关记录'); </script>");
GridView1.DataSource = result.Tables[0];
GridView1.DataKeyNames = new string[] { "dno" };
GridView1.DataBind();
}
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Attributes.Add("onclick", "return confirm('你确认要删除吗?')");
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Int32.Parse(());
string id = GridView1.Rows[index].Cells[1].Text;
if ( == "edits")
{
Response.Redirect("modify_dw.aspx?id=" + id);
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
删除点了之后弹出是否确认删除 点确认之后无效果 不知道错在哪里了求解