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