AsyncPostBackTrigger仅在第一次工作 [英] AsyncPostBackTrigger works only the first time
本文介绍了AsyncPostBackTrigger仅在第一次工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含gridview的更新面板. 该网格具有一个下拉列表列.
I have an update panel that includes a gridview. This grid has a drop down list column.
测试版aspx代码:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" EnablePartialRendering="false" UpdateMode="Conditional">
...
<asp:GridView ID="Gv_Queue" runat="server">
<Columns>
<asp:TemplateField HeaderText="H">
<ItemTemplate>
<asp:DropDownList ID="ddl_proprietà" runat="server" OnSelectedIndexChanged="ddl_proprietà_SelectedIndexChanged" AutoPostBack="true"/>
</ItemTemplate>
</Columns>
</asp:GridView
</asp:UpdatePanel>
我通过代码在UpdatePanel中添加DDL的触发器:
I add the triggers of the DDL in the UpdatePanel by code:
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = dl.UniqueID; //dl is the Drop Down control
UpdatePanel1.Triggers.Add(trigger);
在第一个selectedIndexChanged事件上效果很好...但是第二次触发该事件时,触发器无法正常运行,因为运行了回发操作.
It works good at the fist selectedIndexChanged event... but the second time that the event is fired the trigger does not work correctly because a post back operation runs.
我已经尝试过:
- 要将AsyncPostBackTrigger更改为PostBackTrigger,但缺少 抛出组件异常.
- 将UpdatePanel属性中的updateMode更改为始终".
- 仅在
的ItemTemplate列中放置另一个UpdatePanel 下拉菜单.
- to change the AsyncPostBackTrigger to a PostBackTrigger but a missing component exception is thrown.
- change the updateMode in theUpdatePanel attribute to 'Always'.
- Put another UpdatePanel in the ItemTemplate Column only for the
DropDown.
推荐答案
在我的情况下,问题是因为页面上有2个具有相同ID的控件.如果以前的答复不能解决问题,则可能需要检查一下.
In my case the issue was because I had 2 controls on the page with the same Id. You may want to check this out if the previous responses did not resolve the issue.
这篇关于AsyncPostBackTrigger仅在第一次工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文