Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3352644
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:03:18+00:00 2026-05-18T02:03:18+00:00

This is probably something fundamental and stupid that I’ve missed, but the various workarounds

  • 0

This is probably something fundamental and stupid that I’ve missed, but the various workarounds are causing me such huge headaches that really, I need to understand the basic problem here in order to find the best solution.

I have a usercontrol which contains a drop-down list.

<asp:DropDownList ID="ddlOrderStatus" AutoPostBack="true" runat="server" CssClass="textbox">
   <asp:ListItem value="8">Pending</asp:ListItem>
   <asp:ListItem value="9">On Hold</asp:ListItem>
   <asp:ListItem Value="11">Complete</asp:ListItem>
   <asp:ListItem Value="12">Cancelled</asp:ListItem>             
 </asp:DropDownList>

It does nothing in its Page_Load event.

This is in turn contained in a page which, in it’s Page_Load event does some databinding on some repeater controls on the page but doesn’t touch the control containing the ddl. There is no ajax on the page.

The dropdownlist is – clearly – set to autopostback = true. The postback code looks like this:

Private Sub ddlOrderStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlOrderStatus.SelectedIndexChanged
    Dim ddl As DropDownList = DirectCast(sender, DropDownList)
    Dim currentsorting As String = Request.QueryString("sort")
    Dim currentpaging As String = Request.QueryString("page")
    Response.Redirect(String.Format("~/admin/orders/Manage/0?sort={0}&page={1}&status={2}", currentsorting, currentpaging, ddl.SelectedValue))
End Sub

So when the ddl is changed, the page actually does a double postback. I see no way to avoid this as I need to do a postback to get the value in the ddl and then another postback to get some new data from the server based on that value.

Anyway, the long and the short of it is that when you do this the dropdownlist fails to maintain its state. So you select a value, the code does the job it’s supposed to – gets the selected value then posts back again returning the new expected set of data – and then on loading again the dropdownlist is back in its default form.

This is a pernicious problem for me because of that double-postback: if I try and set the value of the ddl to equal what’s in the querystring I have, effecitvely, set it to that value permanently because Page_Load – where the value is set – occurs before events are processed and so the value stays unchanged. I tried moving the code which changed the selectedvalue of the ddl into Render, but it seemed that although the selected value had changed as far as the user could see, the selected value was still the default value during processing and was treated as such.

I also tried setting the selectedValue in session and then clearing it as soon as it was populated. That worked for some scenarios, but unfortunately this page also contains some javascript that can cause it to post back – and you can’t set session from client-side javascript. So that idea had to go out the window.

I’m at a loss here – this apparently simple problem has eaten a whole day of my time. Can anyone either tell me why state isn’t being maintained on this control and/or suggest a way I get it to show the right value after postback without turning the selection into a permanent one?

Cheers,
Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:03:19+00:00Added an answer on May 18, 2026 at 2:03 am

    In your page load:

    // Only set the selected order status when the page first loads, but not on postbacks.
    if( !Page.IsPostback )
    {
        ddlOrderStatus.SelectedValue = Request.QueryString("status");
    }
    

    Footnote:

    I see no way to avoid this as I need
    to do a postback to get the value in
    the ddl and then another postback to
    get some new data from the server
    based on that value.

    You could do it from javascript

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm probably doing something realy stupid but I cant get this to work: var
This is probably a pretty basic question, but just something that I wanted to
This is probably something stupid, but I really can't figure it out myself. I'm
this is probably something stupid, but i can't figure it out. I'm getting a
This is probably something ridiculously stupid, but I've gone over this code again and
This is probably something stupid I am missing but it has really got me
This is probably something pretty silly that I'm missing but how do I get
This is probably something really simple but for some reason I just can't seem
This has probably something to do with my transformations, but right now I can't
This is probably something silly I'm missing but I'm definitely lost. I'm using .NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.