ASP.NET行变色,及禁用编辑,删除按钮

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //当鼠标移到行上时更改背景色
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#8AC8F3'");
            //当鼠标移开时还原背景色
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            //编辑按钮禁用
            LinkButton EditBt = (LinkButton)(e.Row.Cells[16].FindControl("LinkButton1"));
            EditBt.Enabled = false;
            //删除按钮禁用
            LinkButton DeletBt = (LinkButton)(e.Row.Cells[16].FindControl("LinkButton2"));
            DeletBt.Enabled = false;
        }

    }

你可能感兴趣的:(asp.net)