Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.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#_Gridview - Fatal编程技术网

C# Gridview行命令事件

C# Gridview行命令事件,c#,gridview,C#,Gridview,我有一个gridview,其中boundfield是这样的- <asp:BoundField HeaderText="Approved" /> 但它没有显示我想要显示的所需文本。有人能给我推荐可能的解决方案吗?使用模板字段而不是边界字段,如下所示: <asp:TemplateField HeaderText="Approved"> <ItemTemplate> <asp:Label id="LabelApproved" ru

我有一个gridview,其中boundfield是这样的-

 <asp:BoundField  HeaderText="Approved" />

但它没有显示我想要显示的所需文本。有人能给我推荐可能的解决方案吗?

使用
模板字段而不是
边界字段,如下所示:

<asp:TemplateField HeaderText="Approved">
    <ItemTemplate>
        <asp:Label id="LabelApproved" runat="server"/>
    </ItemTemplate>
</asp:TemplateField>

不要使用
BoundField
而使用
TemplateField
,如下所示:

<asp:TemplateField HeaderText="Approved">
    <ItemTemplate>
        <asp:Label id="LabelApproved" runat="server"/>
    </ItemTemplate>
</asp:TemplateField>
protected void gwFacultyStaff_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName.Equals("Yes"))     
    {
        GridViewRow row = (GridViewRow)((Button)e.CommandSource).NamingContainer;
        Label theLabel = row.FindControl("LabelApproved") as Label;
        theLabel.Text = "TRUE";
    }
    else if (e.CommandName.Equals("No"))
    {
        GridViewRow row = (GridViewRow)((Button)e.CommandSource).NamingContainer;
        Label theLabel = row.FindControl("LabelApproved") as Label;
        theLabel.Text = "FALSE";
    }
}