博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

GridView中删除弹出对话框及荧光棒效果

Posted on 2009-08-19 15:26  小鞠  阅读(727)  评论(1)    收藏  举报

    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);
        }
    }