Reputation: 25280
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
Upvotes: 0
Views: 11658
Reputation: 26190
Could you use a template field instead of a command field, and forcibly update (UpdatePanel.Update()) the panel when the command button is clicked?
Upvotes: 0
Reputation: 44916
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.
Upvotes: 0
Reputation: 2226
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.
Upvotes: 0