Solved

Issues with UpdatePanel using DropDownList and Button together

Posted on 2010-09-04
2
675 Views
Last Modified: 2012-05-10
I have a UpdatePanel that contains 2 DropDownList controls, a Button and a Gridview control. When you select the first dropdown which contains state it calls the eventhandler to populate the second dropdown with the cities from that state.

The problem comes in that when you press the button, it does not call its eventhandler. But if I press the button prior to selecting a state, it will fire the eventhandler. Can someone please help with this issue. My markup is below.

<asp:UpdatePanel ID="updSearch" UpdateMode="Conditional" runat="server">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
    </Triggers>
    <ContentTemplate>
        <asp:DropDownList ID="lstState" AutoPostBack="true" OnSelectedIndexChanged="lstState_SelectedIndexChanged" runat="server" /><br />
        <asp:DropDownList ID="lstCity" runat="server" />
       
        <div  class="divPlaceHolderRow"><br /></div>        
        <div class="divPlaceHolderRow"><asp:Button ID="btnSearch" OnClick="btnSearch_Click" runat="server" Text="Search" /><br /></div>
        <div class="divPlaceHolderRow"><br /></div>
        <div id="DivSearchGrid">
            <asp:GridView ID="grdPharmacy"
                            CssClass="GridViewSearch"  
                            runat="server"
                            Visible="true"
                            OnRowCommand="grdPharmacy_RowCommand"
                            HorizontalAlign="Center"
                            PagerSettings-Visible="true"              
                            AllowPaging ="true"  
                            AllowSorting="true"
                            Caption="Search Results"
                            CaptionAlign="Left"
                            ShowHeader="true"
                            ShowFooter="true" >                 
            <SelectedRowStyle BackColor="Beige" />
            <HeaderStyle CssClass="GridHeader" />
            <RowStyle CssClass="GridRow" />
            <FooterStyle ForeColor="Green" />
            <SelectedRowStyle CssClass="GridSelected" />  
            <PagerStyle CssClass="GridPager" />
            <PagerSettings Mode="NextPrevious"
                            NextPageText="Next >" 
                            PreviousPageText="< Prev" />                        
            </asp:GridView>
        </div>

    </ContentTemplate>      
</asp:UpdatePanel>
0
Comment
Question by:rawcoder
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 33608764
My first guess would be that the button is the only async post-back trigger, so when the DropDownList is selected, the AutoPostBack=true forces a post-back, which is not a trigger for the UpdatePanel...
0
 

Author Closing Comment

by:rawcoder
ID: 33721570
This was part of the issue. It also had to do with the update panels I was using.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question