页面代码:
CommandName="update" CommandArgument='<%# Eval("AdminID") %>' >
后台代码:
protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "update")
{
int id = obj.ObjToInt32(e.CommandArgument);
Response.Redirect("UpdateAdministrator.aspx?id="+id);
}
else if (e.CommandName == "delete")
{
if (bll.Delete(obj.ObjToInt32(e.CommandArgument)) == 1)
{
Common.AlertMessage.Show(this.Page, "删除成功!");
LoadData();
}
else
{
Common.AlertMessage.Show(this.Page, "删除失败!");
}
}
}
protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
protected void gvList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
}
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "s=this.style.backgroundColor;this.style.backgroundColor='#799AE1'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=s");
}
}