Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何禁用GridView行的单元格?_C#_Asp.net_Asp.net 4.0 - Fatal编程技术网

C# 如何禁用GridView行的单元格?

C# 如何禁用GridView行的单元格?,c#,asp.net,asp.net-4.0,C#,Asp.net,Asp.net 4.0,我有一个GridView控件,它的前两列有按钮。创建行时,我想检查第六列文本是否“锁定”。如果是,则第一个单元格中的按钮不应可见 GridView的前两列如下所示: 您需要执行以下操作以将按钮控件从单元格中删除 protected void GridView1_DataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow)

我有一个
GridView
控件,它的前两列有按钮。创建行时,我想检查第六列文本是否“锁定”。如果是,则第一个单元格中的按钮不应可见

GridView
的前两列如下所示:


您需要执行以下操作以将按钮控件从单元格中删除

protected void GridView1_DataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[5].Text=="Locked")
            {
                (e.Row.FindControl("idofButton1") as Button).Visible=false;
            }
        }
    }

您需要执行以下操作以将按钮控件从单元格中删除

protected void GridView1_DataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[5].Text=="Locked")
            {
                (e.Row.FindControl("idofButton1") as Button).Visible=false;
            }
        }
    }
创建一个CSS类

.invisible
{ 
   display:none;
}


protected void GridView1_DataBound(object sender, GridViewRowEventArgs e)
 {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        if (e.Row.Cells[5].Text=="Locked")
        {
              e.Row.Cells[0].CssClass = "invisible"
        }
     }
   }
创建一个CSS类

.invisible
{ 
   display:none;
}


protected void GridView1_DataBound(object sender, GridViewRowEventArgs e)
 {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        if (e.Row.Cells[5].Text=="Locked")
        {
              e.Row.Cells[0].CssClass = "invisible"
        }
     }
   }

确保这是
GridView1.RowDataBound
的事件,因此更好的名称是
GridView1\u RowDataBound(对象发送方,gridviewEventArgs e){…}
确保这是
GridView1.RowDataBound.RowDataBound的事件,因此更好的名称是
GridView1\u RowDataBound(对象发送方,gridviewEventArgs e){…}