1

I am annoyed with a problem I have repeater control in updatepanel like this.

<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>

The problem I face that whenever I select any value from dropdown all the page gets refreshed After spending hours on the google I found a solution i.e, on itemdatabound event of repeater we just need to add the following code after finding the dropdown,

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

It worked very well for the dropdown but same is not working for checkboxlist like using the scripmanager instance if I write sm.RegisterAsyncPostBackControl(chkBoxListRegistrantBenefits), it is not working :(

3
  • You have to specify a <Triggers> section in the update panel and declare your dropdown and checkbox as AsyncPostBackTriggers. Nov 16, 2011 at 14:56
  • @JimSchubert: That shouldn't be necessary, but it might still solve his problem. Nov 16, 2011 at 15:02
  • Try adding ClientIDMode="AutoID" to the Repeater control. You should not have to add any triggers and you should not even have to call RegisterAsyncPostBackControl. The ChildrenAsTriggers should take care of that.
    – kevev22
    Nov 16, 2011 at 15:11

3 Answers 3

2

Add ClientIDMode="AutoID" to the Repeater control.

You should not have to add any triggers and you should not even have to call RegisterAsyncPostBackControl. The ChildrenAsTriggers should take care of that.

1
  • +1. This is interesting that ClientIDMode causes the asynchronous postbacks to act differently than in previous versions. However, ClientIDMode is only available in ASP.NET 4.0 and wouldn't solve this issue in previous version of ASP.NET. Nov 16, 2011 at 19:28
1

on Repeater ItemDataBound event

use screiptmanager method RegisterAsyncPostBackControl

this.ScriptManager1.RegisterAsyncPostBackControl( e.Item.FindControl(" put here your checkbox ID "));

0

Add this Before start of <ContentTemplate>:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="objDropdownlist" EventName="OnSelectedIndexChanged" />
</Triggers>
3
  • 2
    @Bhargav, please read meta.stackexchange.com/questions/22186/…. Unformatted XML markup is not visible and can make an answer impossible to understand. Nov 16, 2011 at 15:15
  • I tried this way but got an error! The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases Nov 16, 2011 at 15:31
  • remove AutoPostBack="true" event because AsyncPostBackTrigger do same thing. Nov 16, 2011 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.