gridview 根据条件更改链接的可用和颜色

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

 if (e.Row.RowType == DataControlRowType.DataRow)

{

 DataRowView drv = (DataRowView)e.Row.DataItem;

            if (drv.Row["Fetch_status"].ToString() == "已领")

            {

                LinkButton lbtn = e.Row.FindControl("lbtnReg") as LinkButton;

                lbtn.Enabled = false;              

                lbtn.ForeColor = System.Drawing.Color.Gray;

        

         //某一列不显示

         GridView1.Columns[2].Visible = false;



            } 

       else if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)

            {

                LinkButton lbtn = e.Row.FindControl("LinkButton1") as LinkButton;

               

                lbtn.Attributes.Add("onclick", "return confirm('你确定要删除此数据吗?') ");



            }  

}



}

你可能感兴趣的:(GridView)