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;
}
试试FindControl