asp怎么样获取GridView的FooterTemplate模板中的LinkBotton,在从后台代码中把他不显示出来?
6 回答
慕少森
楼主再试试.
TA贡献2019条经验 获得超9个赞
GridView.FindControl("buttonid")
代码如下.
页面的gridview:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="fcdm"
DataSourceID="ObjectDataSource1" ShowFooter="True"
ondatabound="GridView1_DataBound">
<Columns>
<asp:TemplateField HeaderText="fcdm" SortExpression="fcdm">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("dm") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("dm") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="fcmc" SortExpression="fcmc">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("mc") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("mc") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="LinkButton3" runat="server">LinkButton</asp:LinkButton></FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
后台代码:
protected void GridView1_DataBound(object sender, EventArgs e)
{
GridView1.FooterRow.FindControl("LinkButton3").Visible = false;
}
动漫人物
TA贡献1815条经验 获得超10个赞
GridView1.FooterRow.FindControl("LinkButton3").Visible = false;
我用这种但是LinkButton还是没有被隐藏..
慕尼黑8549860
TA贡献1818条经验 获得超11个赞
(GridView1.FooterRow.FindControl("LinkButton3") as LinkButton).Visable = false
试试类似的代码
- 6 回答
- 0 关注
- 497 浏览
添加回答
举报
0/150
提交
取消