GridView里面的ImageButton怎么写删除事件啊?CommandName="Delete"也设置了!在RowDeleting里面写的没反
<asp:ImageButtonID="ImageButton1"runat="server"CommandName="Delete"/>然后onrowdeleting=...
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Delete" />
然后onrowdeleting="dgxs_RowDeleting" 后台 protected void dgxs_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string xjh = dgxs.DataKeys[e.RowIndex]["xjh"].ToString();
string id = dgxs.DataKeys[e.RowIndex]["id"].ToString();
string sql = "delete xjb where xhj='"+xjh+"' and id='"+id+"'";
try
{
int result = new DBhelp().ExecuteNonQuery(sql);
if (result > 0)
{
Response.Write("<script language=javascript>window.alert('删除成功');</script>");
}
else
{
Response.Write("<script language=javascript>window.alert('删除失败');</script>");
}
}
catch (Exception ex)
{
Response.Write("<script language=javascript>window.alert('" + ex + "');</script>");
}
}也都没反应 展开
然后onrowdeleting="dgxs_RowDeleting" 后台 protected void dgxs_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string xjh = dgxs.DataKeys[e.RowIndex]["xjh"].ToString();
string id = dgxs.DataKeys[e.RowIndex]["id"].ToString();
string sql = "delete xjb where xhj='"+xjh+"' and id='"+id+"'";
try
{
int result = new DBhelp().ExecuteNonQuery(sql);
if (result > 0)
{
Response.Write("<script language=javascript>window.alert('删除成功');</script>");
}
else
{
Response.Write("<script language=javascript>window.alert('删除失败');</script>");
}
}
catch (Exception ex)
{
Response.Write("<script language=javascript>window.alert('" + ex + "');</script>");
}
}也都没反应 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询