使用 GridView asp:ButtonField 为更新面板设置异步触发器
从 GridView 控件中为带有 asp:ButtonField
的 UpdatePanel
设置 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
我需要保留 UpdateMode
和ChildrenAsTriggers
属性设置为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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.
Lance Harper 提到的所有内容都是正确的,但您还需要删除以下属性:
拥有该属性将阻止客户端事件的自动连接。 本质上,您是在告诉 ASP.Net 您将自己执行此操作。
Everything that Lance Harper mentioned is true, but you also need to remove the following attribute:
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.
您可以使用模板字段而不是命令字段,并在单击命令按钮时强制更新(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?