首页 新闻 搜索 专区 学院

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

0
悬赏园豆:20 [已解决问题] 解决于 2011-02-24 15:42

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

蝸牛漫步的主页 蝸牛漫步 | 初学一级 | 园豆:0
提问于:2011-02-24 14:06
< >
分享
最佳答案
0

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

收获园豆:20
Localhost | 菜鸟二级 |园豆:443 | 2011-02-24 14:18
GridView1.FooterRow.FindControl("LinkButton3").Visible = false; 我用这种但是LinkButton还是没有被隐藏..
蝸牛漫步 | 园豆:0 (初学一级) | 2011-02-24 14:28
楼主试试我上面的代码.
Localhost | 园豆:443 (菜鸟二级) | 2011-02-24 14:50
//下一页 protected void LinkButton7_Click(object sender, EventArgs e) { GridView1.FooterRow.FindControl("LinkButton3").Visible = true ; GridView1.FooterRow.FindControl("LinkButton4").Visible = true; if(Convert.ToInt32(ViewState["index"])<Convert.ToInt32(ViewState["sum"])) { pageindex = Convert.ToInt32(ViewState["index"]) + 1; ViewState["index"] = pageindex; GridView1.DataSource = BLL.ClienteleNodeBLL.Proc_selectindex(pageindex - 1, pagesize); GridView1.DataBind(); } }
蝸牛漫步 | 园豆:0 (初学一级) | 2011-02-24 15:00
在我的下一页事件中,我想把 GridView1.FooterRow.FindControl("LinkButton3").Visible = true ; 但是有不可以了....?您有方法解决吗?
蝸牛漫步 | 园豆:0 (初学一级) | 2011-02-24 15:02
是不是只要第一页时不显示,以后都显示啊?
Localhost | 园豆:443 (菜鸟二级) | 2011-02-24 15:06
恩...我刚可以用Bool变量解决 点下一条就为TRUE!就行了,嘿嘿
蝸牛漫步 | 园豆:0 (初学一级) | 2011-02-24 15:14
恩,也可以使用PageIndexChanged事件来解决.
Localhost | 园豆:443 (菜鸟二级) | 2011-02-24 15:15
其他回答(1)
0

试试FindControl

Jerry Chou | 园豆:2642 (老鸟四级) | 2011-02-24 14:10
GridView1.FooterRow.FindControl("LinkButton3").Visible = false; 我用这种但是LinkButton还是没有被隐藏..
支持(0) 反对(0) 蝸牛漫步 | 园豆:0 (初学一级) | 2011-02-24 14:18
(GridView1.FooterRow.FindControl("LinkButton3") as LinkButton).Visable = false 试试类似的代码
支持(0) 反对(0) Jerry Chou | 园豆:2642 (老鸟四级) | 2011-02-24 14:21
这段代码我试了,点了没有反应,也不报错..
支持(0) 反对(0) 蝸牛漫步 | 园豆:0 (初学一级) | 2011-02-24 14:27
@蝸牛漫步: void OrderGridView_RowCreated(Object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Footer) { // Get the OrderTotalLabel Label control in the footer row. Label total = (Label)e.Row.FindControl("OrderTotalLabel"); // Display the grand total of the order formatted as currency. if (total != null) { total.Text = orderTotal.ToString("c"); } } } http://goo.gl/mTmWz
支持(0) 反对(0) Jerry Chou | 园豆:2642 (老鸟四级) | 2011-02-24 14:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册