更新面板更新

发布于 2024-08-03 04:43:07 字数 1216 浏览 2 评论 0原文

我有一个更新面板,里面有一个网格。网格的数据将取决于用户

在搜索文本框中插入的内容。他们将单击“搜索”,然后在客户端,网格会通过

我使用的一些 Ajax 动画滑入。我的问题是我希望网格重新加载

搜索框中的文本作为参数数据。如何在单击该

按钮时重新加载该网格的更新面板?

<font color="blue">Search:</font><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/bttnSearch.gif" Height="19" />
</p>
<div id="moveMe" style="display:">
    <div style="float:right;">
    <asp:LinkButton ID="lnkBtnCloseColHelp" runat="server" Text="X" OnClientClick="return false;" />
  </div>
<br /><br />
<center>
     <table>
     <tr>
        <td>
             <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
             <ContentTemplate >
                    //Gridview and SqlDatasource goes here.
             </ContentTemplate>   
              <Triggers>
                <asp:AsyncPostBackTrigger ControlID = "ImageButton2" EventName = "Click"/>
             </Triggers> 
             </asp:UpdatePanel> 

我的网格不会加载,因为它需要在文本框中获取该数据。该文本框也应该位于更新面板内部吗?关于如何在点击搜索按钮后根据文本框的文本重新加载网格的任何想法。

I have and Update Panel with a Grid inside of it. The grid's data will depend on a what a user

inserts into a Search textbox. They will click Search and on clientside the grid slides in via

some Ajax animations i used. My issue is the I want the grid to reload with the text in the

search box as it's parameter data. How do I reload that Grid's Update Panel on click of that

button?

<font color="blue">Search:</font><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/bttnSearch.gif" Height="19" />
</p>
<div id="moveMe" style="display:">
    <div style="float:right;">
    <asp:LinkButton ID="lnkBtnCloseColHelp" runat="server" Text="X" OnClientClick="return false;" />
  </div>
<br /><br />
<center>
     <table>
     <tr>
        <td>
             <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
             <ContentTemplate >
                    //Gridview and SqlDatasource goes here.
             </ContentTemplate>   
              <Triggers>
                <asp:AsyncPostBackTrigger ControlID = "ImageButton2" EventName = "Click"/>
             </Triggers> 
             </asp:UpdatePanel> 

My Grid won't load because It needs to get that data in the textbox. Should that textbox be inside of the updatepanel also? Any Ideas on how i can get the Grid alone to reload based on the textbox's text after the search button is hit.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

猫七 2024-08-10 04:43:07

这样“黑客”怎么样?在 UpdatePanel 中有一个虚拟的隐藏文本框或隐藏字段控件。单击按钮时,将实际文本框值在客户端复制到隐藏控件。不优雅但应该可以。

其他信息:
如果触发器设置为AsyncPostBack:

    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button1">
        </asp:AsyncPostBackTrigger>
    </Triggers>

回发实际上获取的是UpdatePanel之外的所有控件的值。所以根本不需要我的 hack。

How about 'hacking' this way. Have a dummy hidden textbox or hidden field control within the UpdatePanel. Perform a client-side copy of the actual textbox value to the hidden control when the button is clicked. Not elegant but should work.

Additional Info:
If the trigger is set as AsyncPostBack:

    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button1">
        </asp:AsyncPostBackTrigger>
    </Triggers>

The postback actually gets the values of all the controls outside the UpdatePanel. So my hack is not required at all.

你又不是我 2024-08-10 04:43:07

是的,这有点模糊,所以我的答案也是如此。您必须在后面的代码中处理图像按钮的单击事件。此时,您将需要使用更新的结果重新绑定网格视图。

Yeah, this is a little vague, so my answer will be as well. You will have to handle the click event of the image button in your code behind. At that point you will need to rebind the gridview with the updated results.

冷夜 2024-08-10 04:43:07

您可以将这两个部分放在不同的更新面板中。

您可以拥有一个包含搜索框输入和图像按钮的更新面板,以及另一个包含网格控件的更新面板。

You can probably put both of those sections in different update panels.

You can have one update panel containing the search box input and image button, and another one containing your grid control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文