在c#中禁用寻呼机模板上的图像按钮(Disable image button on Pager Template in c#)

编程入门 行业动态 更新时间:2024-10-24 00:31:38
在c#中禁用寻呼机模板上的图像按钮(Disable image button on Pager Template in c#)

我在ASP.NET c#和MySQL数据库中工作。

在我的gridView中,我添加了此代码分页。

<PagerTemplate> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="/Images/bot_back_1.gif" CommandArgument="First" CommandName="Page" Visible="true" /> <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="/Images/bot_back.gif" CommandArgument="Prev" CommandName="Page" Visible="true" /> Page <asp:DropDownList ID="ddlPages" runat="server" AutoPostBack="True" CssClass="ddl_Class" OnSelectedIndexChanged="ddlPages_SelectedIndexChanged" Visible="true"> </asp:DropDownList> of <asp:Label ID="lblPageCount" runat="server"></asp:Label> <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="/Images/bot_next.gif" CommandArgument="Next" CommandName="Page" Visible="true" /> <asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="/Images/bot_next_1.gif" CommandArgument="Last" CommandName="Page" Visible="true" /> </PagerTemplate> </asp:GridView> <asp:ImageButton ID="btnAdd" runat="server" Visible="true" OnClick="btnAdd_Click" ImageUrl="/Images/Add_button.gif" />

现在我需要在激活时将PagerTemplate上的所有内容设置为可见false:

protected void btnAdd_Click(object sender, ImageClickEventArgs e) { gvProducts.ShowFooter = true; btnAdd.Visible = false; BindData(); }

我尝试过:

protected void btnAdd_Click(object sender, ImageClickEventArgs e) { gvProducts.ShowFooter = true; btnAdd.Visible = false; ImageButton1.Visible = false; BindData(); }

但我有错误:

CS0103:当前上下文中不存在名称“ImageButton1”。

你能帮我解决一下这个问题吗?

提前致谢。

I work in ASP.NET c# and MySQL database.

In my gridView I have added this code pagination.

<PagerTemplate> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="/Images/bot_back_1.gif" CommandArgument="First" CommandName="Page" Visible="true" /> <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="/Images/bot_back.gif" CommandArgument="Prev" CommandName="Page" Visible="true" /> Page <asp:DropDownList ID="ddlPages" runat="server" AutoPostBack="True" CssClass="ddl_Class" OnSelectedIndexChanged="ddlPages_SelectedIndexChanged" Visible="true"> </asp:DropDownList> of <asp:Label ID="lblPageCount" runat="server"></asp:Label> <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="/Images/bot_next.gif" CommandArgument="Next" CommandName="Page" Visible="true" /> <asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="/Images/bot_next_1.gif" CommandArgument="Last" CommandName="Page" Visible="true" /> </PagerTemplate> </asp:GridView> <asp:ImageButton ID="btnAdd" runat="server" Visible="true" OnClick="btnAdd_Click" ImageUrl="/Images/Add_button.gif" />

Now I need to set as visible false all the content on PagerTemplate when is activate :

protected void btnAdd_Click(object sender, ImageClickEventArgs e) { gvProducts.ShowFooter = true; btnAdd.Visible = false; BindData(); }

I have tried with :

protected void btnAdd_Click(object sender, ImageClickEventArgs e) { gvProducts.ShowFooter = true; btnAdd.Visible = false; ImageButton1.Visible = false; BindData(); }

But I have error :

CS0103: The name 'ImageButton1' does not exist in the current context.

Can you please help me figure out the problem?

Thanks in advance.

最满意答案

你必须使用FindControl()方法来确定Control

ImageButton btn = (ImageButton)gvProducts.BottomPagerRow.FindControl("ImageButton1"); btn.Visible = false;

you have to use the method FindControl() to determine the Control

ImageButton btn = (ImageButton)gvProducts.BottomPagerRow.FindControl("ImageButton1"); btn.Visible = false;

更多推荐

本文发布于:2023-08-05 04:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428005.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:寻呼机   按钮   图像   模板   Disable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!