views:

1590

answers:

1

This should be a pretty simple thing to do with Update Panels, but I'm having troubles. I want to update the updatePanelSelectedVendors on vendorsComboBox selection change, when the gridview pages, and on the delete buttons in that panel. I don't want to refresh the vendor combox at all, but I don't want to do a full post back.

The problem is that the async post back only happens the first selection change of the vendorsComboBox. I'm having similar panels with other update panels in this user control. How can I link them all together and only update on the triggers I set.

<div class="containerBox vendorsSelectBox">
    <asp:Label ID="lblVendors" runat="server" EnableViewState="false" AssociatedControlID="vendorsComboBox" CssClass="labelHeader" Text="Vendors" />
    <br />
  <asp:UpdatePanel ID="updatePanelVendorsSelect" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
        <ContentTemplate>
            <ajaxToolkit:ComboBox ID="vendorsComboBox" runat="server"
                            DataTextField="Name"
                            DataValueField="VendorID"
                            AutoPostBack="true"
                            AutoCompleteMode="SuggestAppend"
                            DropDownStyle="DropDownList"
                            CssClass="CustomComboBoxStyle" 
                            CaseSensitive="false"
                            AppendDataBoundItems="false" 
                            onselectedindexchanged="vendorsComboBox_SelectedIndexChanged">
            </ajaxToolkit:ComboBox>
     </ContentTemplate>
   </asp:UpdatePanel>
</div>
<asp:Panel ID="panelSelectedVendors" runat="server" CssClass="containerBox selectedFranchiseBox">            
     <label class="labelHeader">Selected Vendors</label>&nbsp;&nbsp;&nbsp;<br />
     <asp:UpdatePanel ID="updatePanelSelectedVendors" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
         <Triggers>
            <asp:AsyncPostBackTrigger ControlID="vendorsComboBox" EventName="SelectedIndexChanged" />
        </Triggers>
        <ContentTemplate>               
                <asp:GridView ID="selectedVendorsList" runat="server"
                   AllowPaging="True"
                   Width="250"
                   DataKeyNames="VendorID" AutoGenerateColumns="False" SkinID="gridViewSkin" 
                    onrowdatabound="selectedVendorsList_RowDataBound" 
                    onpageindexchanging="selectedVendorsList_PageIndexChanging">                        
                    <Columns>
                        <asp:TemplateField HeaderText="Remove?" ItemStyle-Width="10">
                            <ItemTemplate>
                                <asp:CheckBox ID="checkBoxSelect" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    </Columns>
                </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
    <br />            
    <asp:Button ID="buttonDeleteSelectedVendor" runat="server" 
                Text="Delete Selected Vendor" EnableViewState="false"
                SkinID="button" style="display:none; float:left; width:150px;" 
                onclick="buttonDeleteSelectedVendor_Click" />
    <asp:Button ID="buttonClearSelectedVendors" runat="server"
                Text="Delete All" SkinID="button" style="float:right; margin-right:25px;" 
                Visible="false"
        onclick="buttonClearSelectedVendors_Click" />
 </asp:Panel>

EDIT: I changed vendorsComboBox to a regular DropDownList and the partial post backs worked the way I expected. Why doesn't it with the ComboBox control?

+2  A: 

If you don't want to refresh 'vendorsComboBox', then there's no need for it to be in an UpdatePanel in the first place. Adding it as a trigger to 'updatePanelSelectedVendors' is sufficient to update that UpdatePanel.

As far as having multiple UpdatePanels on the page is concerned, you seem to be doing the most important thing right, that is making sure they have UpdateMode="Conditional", otherwise they all update when any of them does.

Anyway, try removing the 'updatePanelVendorsSelect' panel, as it's not necessary at all, and any others that wrap content that doesn't need to change, and see how you get on. It may solve your problem, it may slightly help, let me know.

Rafe Lavelle
the problem seems to be related to the ajax control toolkit ComboBox. I made an edit pointing to that. Thanks for you answer that confirmed what I thought to be true about the update panels and pointing me in the correct direction (for that I gave an up-vote)
Kevin
no idea why the combo box wouldn't have worked - never used one of them. One thing though: in your edit you say "...the partial post backs worked..." - it's still a full postback with Asp.Net AJAX. It's only a partial re-rendering of the *page*, though.
Rafe Lavelle

related questions