页面载入时通过获取GridView某行某列的值来控制某一列的控件属性

通过获取状态来控制“查看”button的Visible属性值。


     

    在前台GridView中加入 OnRowDataBound="GridView1_RowDataBound“。例如以下:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowSorting="True"
                                    OnRowDataBound="GridView1_RowDataBound" BackColor="White">

  </asp:GridView>

在后台 GridView1_RowDataBound 事件中对控件属性控制。例如以下:

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
        {
                      if (e.Row.Cells[4].Text == "县审核通过")
                {
                    e.Row.Cells[11].Visible = false;   //设置当前选中行第11列为不可见
                }

        }

原文地址:https://www.cnblogs.com/yfceshi/p/7339803.html