Dropdown box stopped working

Discussion in 'ASP .Net Building Controls' started by jonefer, Apr 15, 2008.

  1. jonefer

    jonefer Guest

    Can anyone please suggest things can cause a dropdown box to stop causing a
    postback? (besides unchecking the 'enable postback' box)

    One of the last things I was doing was creating modalpopup extender panels
    which which use update panels that refer to the dropdown box... but I have
    wracked my brain trying to figure it out.

    It's 4AM and i'm trying to meet a deadline... now I'm finally going to sleep.
     
    jonefer, Apr 15, 2008
    #1
    1. Advertisements

  2. Do you have the AutoPostBack property set to True (or is that what you meant
    by 'enable postback')? Also, is the DropDownList inside an UpdatePanel (and
    if it is, what values do you have for the UpdatePanel's properties)? These
    are the only things that come to mind for me to check based on what you have
    said, although it would probably be helpful to see your code if neither of
    these helps.
     
    Nathan Sokalski, Apr 15, 2008
    #2
    1. Advertisements

  3. jonefer

    jonefer Guest

    Yes. AutoPostBack is set to True.
    No. The DropDownlist called (cmbPCP) is not inside an update panel.
    It used to be. (but I changed it in design)- maybe the 'source' aspx
    doesn't match for one reason or another... can you look at this code?

    How can I send it to you... it's too large for the posting?
     
    jonefer, Apr 15, 2008
    #3
  4. I would post as much of the *.aspx file as you think necessary, and the code
    inside the Init, Load, and SelectedIndexChanged event handlers, and anything
    else you think might be significant. This may be a lot of code to post, but
    you're not the first person to need to post a lot of code to a newsgroup
    posting. It's really the only way to get people to bother to look at the
    code, and sometimes people won't even bother looking at the message period
    if a file is attached.
     
    Nathan Sokalski, Apr 15, 2008
    #4
  5. jonefer

    jonefer Guest

    Ok, thank you...

    I tried to paste all of it, but I got an error saying the post could only
    take so much.

    So here are two sections
    The section that has the dropdown list - "cmbPCP" is as follows


    <td style="font-weight: bold; font-size: x-small; width: 67px; color: black;
    font-family: 'Century Gothic'; height: 10px;">
    PCP Name:</td>
    <td style="width: 90px; height: 10px;">

    <asp:DropDownList ID="cmbPCP" runat="server"
    AutoPostBack="True"
    DataTextField="ProvName"
    DataValueField="ProvID" Style="font-weight: bold; font-size: x-small;
    color: black; font-family: 'Century Gothic'"
    Width="234px">
    </asp:DropDownList></td>
    </tr>
    <tr>
    <td colspan="2" rowspan="2" style="height: 66px">

    <asp:DetailsView ID="dvProvider" runat="server"
    AutoGenerateRows="False" DataSourceID="sdsPCPPanel"
    Height="7px" Style="font-weight: normal;
    font-size: x-small; color: black; font-family: 'Century Gothic'"
    Width="319px" GridLines="None">
    <Fields>
    <asp:BoundField DataField="RPTPeriod"
    HeaderText="Report Period:"
    ReadOnly="True"
    SortExpression="RPTPeriod" />
    <asp:BoundField DataField="ProvID"
    HeaderText="PCP Number:" SortExpression="ProvID" />
    <asp:BoundField DataField="LocName"
    HeaderText="Primary Location:" SortExpression="LocName" />
    <asp:BoundField DataField="Specialty"
    HeaderText="Department Specialty:" SortExpression="Specialty" />
    </Fields>
    </asp:DetailsView>

    '=====================================================

    Then there are 8 panels just like this one

    <asp:panel ID="pnlHCC" runat="server" CssClass="modalPopup" Style="display:
    none" Height="323px"
    Width="685px">
    <table style="width: 697px; height: 138px">
    <tr>
    <td style="width: 100px; height: 5px" valign="top">

    <asp:Button ID="btnClose_HCC" runat="server"
    Text="Close" />
    </td>
    </tr>
    <tr>
    <td style="width: 100px; height: 280px" valign="top">

    <asp:UpdatePanel ID="upHCC" runat="server">
    <ContentTemplate>
    <asp:GridView ID="gvHCC" runat="server"
    AllowPaging="True" AllowSorting="True"
    AutoGenerateColumns="False" BackColor="White"
    BorderColor="#E7E7FF" BorderStyle="None"
    BorderWidth="1px" CellPadding="3"
    DataSourceID="odsHCC" EmptyDataText="No 'HCC Left to refresh' Data Exists for
    this Provider"
    GridLines="Horizontal" Width="678px">
    <FooterStyle BackColor="#B5C7DE"
    ForeColor="#4A3C8C" />
    <RowStyle BackColor="#E7E7FF"
    ForeColor="#4A3C8C" />
    <Columns>
    <asp:BoundField DataField="PT_MRN"
    HeaderText="PT_MRN" SortExpression="PT_MRN" />
    <asp:BoundField DataField="PT_NAME"
    HeaderText="PT_NAME" SortExpression="PT_NAME" />
    <asp:BoundField DataField="HCC Left To
    Refresh" HeaderText="HCC Left To Refresh"
    SortExpression="HCC Left To Refresh"
    />
    <asp:BoundField DataField="HCC
    Description" HeaderText="HCC Description" SortExpression="HCC Description" />
    </Columns>
    <PagerStyle BackColor="#E7E7FF"
    ForeColor="#4A3C8C" HorizontalAlign="Right" />
    <SelectedRowStyle BackColor="#738A9C"
    Font-Bold="True" ForeColor="#F7F7F7" />
    <HeaderStyle BackColor="#4A3C8C"
    Font-Bold="True" ForeColor="#F7F7F7" />
    <AlternatingRowStyle BackColor="#F7F7F7" />
    </asp:GridView>
    <asp:ObjectDataSource ID="odsHCC" runat="server"
    OldValuesParameterFormatString="original_{0}"
    SelectMethod="PercentRefresh"
    TypeName="dsListsTableAdapters.tbl_lst_HCCTableAdapter">
    <SelectParameters>
    <asp:ControlParameter ControlID="cmbPCP"
    Name="ProvID" PropertyName="SelectedValue"
    Type="String" />
    </SelectParameters>
    </asp:ObjectDataSource>
    </ContentTemplate>
    </asp:UpdatePanel>
    </td>
    </tr>
    </table>
    <br />

    </asp:panel>
    <ajaxToolkit:ModalPopupExtender ID="mpeHCC" runat="server"
    CancelControlID="btnClose_HCC"
    PopupControlID="pnlHCC" TargetControlID="lnkHCC">
    </ajaxToolkit:ModalPopupExtender>

    This panel was the last one I did, so I'm figuring there maybe something
    here. Although I don't see anything.
     
    jonefer, Apr 16, 2008
    #5
  6. What is it that you are expecting to happen when the user makes a new
    selection from the DropDownList? I noticed that you do not have any Triggers
    specified for the UpdatePanel, which means that only the child controls of
    the UpdatePanel will trigger a callback. The DropDownList should still
    trigger a postback, but it will not be the same as what would happen when
    the DropDownList was a child of the UpdatePanel. You may want to take a look
    at the <triggers> element, which goes inside the <UpdatePanel>. I found it
    much easier to use the UpdatePanel once I started using Triggers, because it
    gave me so much more control over what causes what to happen, without
    needing to worry quite as much about which controls were inside the
    UpdatePanel. If you have not used the triggers element before, feel free to
    ask, and I'm sure there is plenty of help online as well. Good Luck!
     
    Nathan Sokalski, Apr 16, 2008
    #6
  7. jonefer

    jonefer Guest

    I found the problem.
    I accidentally used my Dropdownlist as a trigger for one of those Popup
    panels.

    The trigger for those popup panels is just supposed to be the gridview on
    the panel. This prevents the popup from disappearing during the postback.
    I had to make 11 of those, and I accidentally used the dropdownlist as a
    trigger.
    So of course, the rest of the page would never see that event.

    I'd like to entertain the idea of using just one UpdatePanel?
    Are you saying that if I put the drop down list inside the UpdatePanel
    instead of all the othe controls that I want to be asynchronously updated ---
    that the same thing will happen?
     
    jonefer, Apr 16, 2008
    #7
  8. Glad you found the problem. I don't believe I ever suggested using just one
    UpdatePanel (if I did, I apologize for the misunderstanding). What I was
    suggesting was that you use one UpdatePanel for each area that you may at
    some point want updated independently, and anything that you want to trigger
    the updating of that UpdatePanel add as a Trigger. For example:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false"
    UpdateMode="Conditional">
    <ContentTemplate>
    <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true"/><br/>
    <asp:Button ID="Button1" runat="server" Text="Button"/>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="TextBox1" EventName="TextChanged"/>
    <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click"/>
    </Triggers>
    </asp:UpdatePanel><br/>
    <asp:Button ID="Button2" runat="server" Text="Button"/>

    This code contains an UpdatePanel with three controls, two inside and one
    outside the UpdatePanel. However, the update is triggered only by one of the
    controls inside or the control outside, which shows that you can place
    whatever you want inside the UpdatePanel and still select whichever controls
    you want as Triggers. Also take note of the UpdatePanel's properties. The
    ChildrenAsTriggers="false" tells the UpdatePanel not to use it's children as
    triggers unless they are explicitly declared as triggers in the Triggers
    section. The UpdateMode="Conditional" says not to update the UpdatePanel on
    a regular postback, only when triggered by one of the triggers. As you can
    see, this gives you much more control over where you can place controls,
    making it much easier to adjust your design without changing functionality.
    It can sometimes be useful to have multiple UpdatePanels with the same
    Triggers so that you can place controls between the UpdatePanels that are
    not updated. If you would like to read more about some of this (I'm not
    always good with words when helping people), a wonderful book on ASP.NET
    AJAX that includes lots of information on UpdatePanels (and other parts of
    ASP.NET AJAX) is:

    http://www.microsoft.com/mspress/books/10966.aspx

    Good Luck!
     
    Nathan Sokalski, Apr 16, 2008
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.