使用 GridView asp:ButtonField 为更新面板设置异步触发器

发布于 2024-07-23 07:10:05 字数 1070 浏览 5 评论 0原文

从 GridView 控件中为带有 asp:ButtonFieldUpdatePanel 设置 AsyncPostBackTrigger 的正确语法是什么?

我需要为我的 GridView 中的每个 asp:ButtonField 设置一个“AsyncPostBackTrigger”

这是我的源代码

<asp:UpdatePanel ID="MyUpdatePanel" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
    <Triggers>
    </Triggers>
    <ContentTemplate>
        <asp:GridView ID="MyGridView" runat="server" AutoGenerateColumns="false">       
            <Columns>        
                <asp:ButtonField ButtonType="Link" CommandName="Button1" SelectText="Click Me!" />        
                <asp:ButtonField ButtonType="Link" CommandName="Button2" SelectText="No Click Me!" />    
            </Columns>
        </asp:GridView>
    </ContentTemplate> 
</asp:UpdatePanel>

Update

我需要保留 UpdateModeChildrenAsTriggers 属性设置为 true,因为 UpdatePanel 中包含其他按钮,这些按钮不会刷新 UpdatePanel 控件

What is correct sytnax for setting an AsyncPostBackTrigger for an UpdatePanel with an asp:ButtonField from an GridView control?

I need to set an 'AsyncPostBackTrigger' for each asp:ButtonField in my GridView

Here is my source code

<asp:UpdatePanel ID="MyUpdatePanel" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
    <Triggers>
    </Triggers>
    <ContentTemplate>
        <asp:GridView ID="MyGridView" runat="server" AutoGenerateColumns="false">       
            <Columns>        
                <asp:ButtonField ButtonType="Link" CommandName="Button1" SelectText="Click Me!" />        
                <asp:ButtonField ButtonType="Link" CommandName="Button2" SelectText="No Click Me!" />    
            </Columns>
        </asp:GridView>
    </ContentTemplate> 
</asp:UpdatePanel>

Update

I need to keep the UpdateMode and ChildrenAsTriggers attributes set to true because the I have other button contained within the UpdatePanel that do not refresh the UpdatePanel control

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

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

发布评论

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

评论(3

恏ㄋ傷疤忘ㄋ疼 2024-07-30 07:10:05

ChildrenAsTriggers 属性设置为 true 将导致任何导致更新面板内回发的控件刷新面板。 如果您希望使用更新面板之外的控件来触发该更新面板的刷新,则只需使用触发器元素。 在这种情况下,您甚至不需要触发器元素。

The ChildrenAsTriggers property being set to true will cause any control that causes a postback within the update panel to cause it to refresh. You would only need to use the triggers element if you had a control outside of the update panel you wished to use to trigger the refresh of that update panel. You don't even need the triggers element in this instance.

傾城如夢未必闌珊 2024-07-30 07:10:05

Lance Harper 提到的所有内容都是正确的,但您还需要删除以下属性:

UpdateMode="Conditional"

拥有该属性将阻止客户端事件的自动连接。 本质上,您是在告诉 ASP.Net 您将自己执行此操作。

Everything that Lance Harper mentioned is true, but you also need to remove the following attribute:

UpdateMode="Conditional"

Having that attribute in place will prevent the automatic wire-up of your client side events. Essentially you are telling ASP.Net that you are going to do this yourself.

栀子花开つ 2024-07-30 07:10:05

您可以使用模板字段而不是命令字段,并在单击命令按钮时强制更新(UpdatePanel.Update())面板吗?

Could you use a template field instead of a command field, and forcibly update (UpdatePanel.Update()) the panel when the command button is clicked?

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