protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e");
e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor;this.style.backgroundColor=\"" + "#EFF3F7" + "\"");
ImageButton Ibtn = (ImageButton)e.Row.Cells[3].Controls[0];
Ibtn.Attributes.Add("onclick", "javascript:if(confirm('删除角色后无法恢复,是否确认删除?')){} else{ return false;}");
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string ID = GridView1.DataKeys[int.Parse(e.CommandArgument.ToString())].Value.ToString();
if (e.CommandName.Equals("updateCommand"))
{
Response.Redirect("system_roleUpdate.aspx?ID=" + ID);
}
if (e.CommandName.Equals("deleteCommand"))
{
string SQL1 = "DELETE FROM td_sys_role WHERE I_ID=@I_ID";
SqlParameter[] parameter ={
new SqlParameter("@I_ID",SqlDbType.Int,4)
};
parameter[0].Value = ID;
int num = LiTianPing.SQLServerDAL.DbHelperSQL.ExecuteSql(SQL1, parameter);
if (num > 0)
{
BoundToDataView();
JScript.DialogBox("删除操作成功!", "system_rolelist.aspx");
}
}
}
这样,在删除点击ImageButton控件的时候会两次调用RowCommand函数
网上都说是微软的BUG,等待补丁的发布;郁闷!
解决办法就是把ImageButton 换成 Button 控件或其他形式按钮 如:LinkButton等...
补丁等待中........
浙公网安备 33010602011771号