protected void gvSalary_RowDataBound(object sender, GridViewRowEventArgs e)
//GridView的RowDataBound方法
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//荧光棒效果
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#E5ECF9'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
//删除的对话框
ImageButton ibsDelete = e.Row.FindControl("ibsDelete") as ImageButton;
//("ibsDelete")为GridView中删除按钮的ID
ibsDelete.Attributes.Add("onclick", "return confirm('你确定要删除吗!')");
}
}
//在模版中修改PostBackUrl为执行操作的页面
//CommandName 参数名
//id 和ImageUrl
//删除的方法
protected void gvSalary_RowCommand(object sender, GridViewCommandEventArgs e)
{
int sid = Convert.ToInt32(e.CommandArgument);
if (e.CommandName.Equals("SDelete"))
{
ERMBLL.SalaryManager.deleteList(sid);
string msg = string.Format("<script>alert('{0}');location.href='SalaryList.aspx';</script>","删除成功!!");
Response.Write(msg);
}
}
浙公网安备 33010602011771号