asp怎么样获取GridView的FooterTemplate模板中的LinkBotton?在从后台代码中把他不显示出来?

asp怎么样获取GridView的FooterTemplate模板中的LinkBotton,在从后台代码中把他不显示出来?

繁花不似锦
浏览 498回答 6
6回答

慕少森

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; } 楼主再试试.

慕村9548890

试试FindControl

动漫人物

GridView1.FooterRow.FindControl("LinkButton3").Visible = false; 我用这种但是LinkButton还是没有被隐藏..

慕尼黑8549860

(GridView1.FooterRow.FindControl("LinkButton3") as LinkButton).Visable = false 试试类似的代码

largeQ

这段代码我试了,点了没有反应,也不报错..
打开App,查看更多内容
随时随地看视频慕课网APP