如何刷新打开的弹出扩展面板

发布于 2024-11-28 11:03:19 字数 286 浏览 1 评论 0原文

我有一个网格视图,其中每一行都有按钮。单击此按钮后,将打开模态弹出扩展面板(使用 PanelName.Show())。面板包含一个用户控件,它显示一些标签、文本框等。带有附加信息绑定形式 SqlDataSource。到目前为止,它运行良好。但是,当我单击另一个按钮时,只会显示面板,但内容不会刷新(根据单击的按钮,应显示一些详细信息)。基本上,SqlDataSource_Selecting 方法仅在显示面板弹出窗口时调用,但不再调用。

如何在每次 PanelName.Show() 之后强制刷新(重新加载)面板?

提前致谢。

I have a gridview where I have button for each row. After clicking this button, the Modal PopUp Extender Panel is opened (with PanelName.Show()). The Panel contains a user control, which shows some labels, textboxes,etc. with an additional info binded form SqlDataSource. Until this point it works well. But, when I click another button, the panel is purely shown but the content is not refreshed (based on which button is clicked, some details info should be shown). Basically, the method SqlDataSource_Selecting is called only for the panel popup showing but not anymore.

How can I force panel to be refreshed (reloaded) after each PanelName.Show()??

Thanks in advance.

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

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

发布评论

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

评论(2

贪了杯 2024-12-05 11:03:19

如果我正确理解您的问题,我认为问题是您只需要在用户单击按钮更改所选项目后重新绑定数据绑定控件。您可以使用[ControlName].DataBind() 来执行此操作。这有道理吗?

If I'm understanding your question correctly, I think the problem is that you just need to re-Bind your data bound controls after the user clicks the button to change the Selected item. You can use [ControlName].DataBind() to do that. Does that make sense?

菩提树下叶撕阳。 2024-12-05 11:03:19

这取决于您要刷新的控件是否是DataBound()

换句话说,您是否可以通过使用 DataBind() 方法调用强制控件重新加载自身(使用相同数据或新数据)?
大多数 GUI 控件都有 DataBind() 方法,但如果控件实际上并不使用数据来工作,则该方法毫无用处!

这就是为什么在您的情况下您的面板没有用新数据“刷新”,因为在面板上使用 DataBind() 不会执行任何操作。在整个 GridView 上使用 databind() 是另一回事,应该可行。也许在整个区域放置一个更新面板?如果这样做,您必须小心,行上的正常编辑和其他命令将继续有效。

但是,您可以做的是将 modalpopupextender 放入您的 TemplateField 中,并使用“技巧”,您可以保持服务器回发并仍然触发弹出面板。

    <asp:UpdatePanel ID="upADDMAIN" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Button ID="btnADD" runat="server" Text="NEW LOGIN" BackColor="Blue" Font-Bold="True" ForeColor="#FFFFCC" OnClick="btnADD_Click" />
            <asp:Button ID="btnDUM" runat="server" style="display:none" />
            <div style="height:20px">
            </div>
            <ajaxToolkit:ModalPopupExtender ID="mpeADD" runat="server"
                targetcontrolid="btnDUM" 
                popupcontrolid="upADD" 
                backgroundcssclass="modelbackground">    
            </ajaxToolkit:ModalPopupExtender>
            <asp:UpdatePanel ID="upAdd" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Panel ID="pnlADD" runat="server" Width="700px" HorizontalAlign="Center" CssClass="auto-style10" Height="200px">
..
..
                        <div id="puFTR" class="auto-style17" style="vertical-align: middle">
                            <asp:Button id="btnOK" runat="server" Text="OK" style="width: 80px" OnClick="btnOK_Click" />
                                 
                            <asp:Button id="btnCAN" runat="server" Text="CANCEL" style="width: 80px" OnClick="btnCAN_Click" CausesValidation="False" />
                        </div>
                    </asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
        </ContentTemplate>
    </asp:UpdatePanel>

如您所见,btnDUM 控件是一个使 MPE 工作的虚拟控件,但它实际上并没有被使用,因为它被 style="display:none" 隐藏了。标签。

但是,btnADD 确实有效,因为它调用服务器端的 Click() 方法,该方法会刷新新行上的数据。您可能需要使用一些 jScript 将 ROWINDEX 传递到 Click() 方法中,以便它与 GridView 一起使用。

顺便说一句,在我的例子中,Click() 方法手动“控制”MPE...

protected void btnADD_Click(object sender, EventArgs e)
        {
            ClearADDform();
            mpeADD.Show();
        }

 protected void ClearADDform()
        {
            txtLOGIN.Text = string.Empty;
            cbISActive.Checked = true;
            txtPWD.Text = string.Empty;
            ddlAgent.SelectedIndex = -1;
        }

在我的例子中,上面的代码示例位于 GridView 之外,因此您需要进行调整。

但重点是,您仍然可以使用 Ajax 弹出窗口进行服务器端调用!

祝你好运。

It depends on whether the control(s) you want to refresh are DataBound() or not.

In other words, can you force the control to reload by using a DataBind() method call to force the control to reload itself, with either the same or new data?
Most GUI controls have the DataBind() method, but it's useless if the control is not actually using data to work!

This is why in your case your panel is not "refreshed" with new data because using a DataBind() on the panel does nothing. Using a databind() on the entire GridView is a different story and should work. Maybe place an UPDATEPANEL around the whole lot? If you do you have to be careful your normal edits and other Commands on the rows will continue to work.

However, What you can do is place the modalpopupextender inside your TemplateField, and using a "trick", you can keep your server post backs and still fire the popup panel.

ie

    <asp:UpdatePanel ID="upADDMAIN" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Button ID="btnADD" runat="server" Text="NEW LOGIN" BackColor="Blue" Font-Bold="True" ForeColor="#FFFFCC" OnClick="btnADD_Click" />
            <asp:Button ID="btnDUM" runat="server" style="display:none" />
            <div style="height:20px">
            </div>
            <ajaxToolkit:ModalPopupExtender ID="mpeADD" runat="server"
                targetcontrolid="btnDUM" 
                popupcontrolid="upADD" 
                backgroundcssclass="modelbackground">    
            </ajaxToolkit:ModalPopupExtender>
            <asp:UpdatePanel ID="upAdd" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Panel ID="pnlADD" runat="server" Width="700px" HorizontalAlign="Center" CssClass="auto-style10" Height="200px">
..
..
                        <div id="puFTR" class="auto-style17" style="vertical-align: middle">
                            <asp:Button id="btnOK" runat="server" Text="OK" style="width: 80px" OnClick="btnOK_Click" />
                                 
                            <asp:Button id="btnCAN" runat="server" Text="CANCEL" style="width: 80px" OnClick="btnCAN_Click" CausesValidation="False" />
                        </div>
                    </asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
        </ContentTemplate>
    </asp:UpdatePanel>

As you may see, the btnDUM control is a Dummy to get the MPE to work, but it's not actually used as it's hidden by the style="display:none" tag.

However, the btnADD does work because it calls a Click() method on the server side which does the refresh of data on your new row. You may have to use a little jScript to pass the ROWINDEX into the Click() method for it to work with a GridView.

Incidentally, the Click() method in my case "controls" the MPE manually...

protected void btnADD_Click(object sender, EventArgs e)
        {
            ClearADDform();
            mpeADD.Show();
        }

 protected void ClearADDform()
        {
            txtLOGIN.Text = string.Empty;
            cbISActive.Checked = true;
            txtPWD.Text = string.Empty;
            ddlAgent.SelectedIndex = -1;
        }

In my case, the above code example is outside a GridView, so you'll need to adjust.

But the point is, you can still have Server Side calls using Ajax popups!

Good luck.

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