2011-11-16 55 views
0

我很烦恼的问题,我有这样的updatepanel中的重复控制。页面刷新在点击checboxlist在中继器

<asp:UpdatePanel ID="UpdPnlConstituentRepeater" ChildrenAsTriggers="true" runat="server"> 

          <ContentTemplate> 
           <asp:Repeater ID="repConstituentInformation" runat="server" OnItemDataBound="repConstituentInformation_ItemDataBound"> 
<ItemTemplate> 
<asp:DropDownList ID="dropRegistrantDownCostType" runat="server" AppendDataBoundItems="true" 
                 AutoPostBack="true" OnSelectedIndexChanged="dropRegistrantDownCostType_SelectedIndexChanged" 
                 EnableViewState="true"> 
                 <asp:ListItem Text="Select Type" Value="0" Selected="True" /> 
                </asp:DropDownList> 

<asp:CheckBoxList ID="chkBoxListRegistrantBenefits" AutoPostBack="true" runat="server" 
                 OnSelectedIndexChanged="chkBoxListRegistrantBenefits_SelectedIndexChanged"> 
                </asp:CheckBoxList> 
</itemTemplate> 
</ContentTemplate> 
</asp:UpdatePanel> 

我的脸,每当我选择从下拉列表中所有的页面被刷新的谷歌花了几个小时后,我找到了一个解决方案,即,对直放站的ItemDataBound事件的任何值,我们只需要后添加以下代码的问题发现下拉菜单,

Dim sm As ScriptManager = ScriptManager.GetCurrent(Page) 
      sm.RegisterAsyncPostBackControl(objDropdownlist) 

它工作得很好下拉,但同样是不工作的CheckBoxList的一样,如果我写sm.RegisterAsyncPostBackControl(chkBoxListRegistrantBenefits)使用scripmanager例如,它不工作:(

+0

您必须指定在更新面板中的''部分,声明你的下拉列表,并作为复选框[AsyncPostBackTrigger](http://msdn.microsoft.com/en-us/library/system.web.ui.asyncpostbacktrigger的.aspx)秒。 –

+0

@JimSchubert:这不应该是必要的,但它仍然可以解决他的问题。 –

+0

尝试将'ClientIDMode =“AutoID”'添加到Repeater控件。你不应该添加任何触发器,你甚至不需要调用RegisterAsyncPostBackControl。 'ChildrenAsTriggers'应该照顾到这一点。 – kevev22

回答

1

添加ClientIDMode="AutoID"到Repeater控件。

你不应该添加任何触发器,你甚至不需要拨打RegisterAsyncPostBackControlChildrenAsTriggers应该照顾。

+0

+1。这很有趣,ClientIDMode会导致异步回发的行为与之前的版本不同。但是,'ClientIDMode'仅在ASP.NET 4.0中可用,并不能解决以前版本的ASP.NET中的这个问题。 –

0

添加在此之前的<ContentTemplate>开始:

<Triggers> 
    <asp:AsyncPostBackTrigger ControlID="objDropdownlist" EventName="OnSelectedIndexChanged" /> 
</Triggers> 
+2

我希望你没有完成... –

+2

@Bhargav,请阅读http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks。未格式化的XML标记不可见,可能使答案无法理解。 –

+0

谢谢先生,我想找到,谢谢告诉我。 –

1

对直放站ItemDataBound事件

使用screiptmanager方法RegisterAsyncPostBackControl

this.ScriptManager1.RegisterAsyncPostBackControl( e.Item.FindControl( “把这里你复选框ID”));