RE: DropDownList SelectedValue is always first value

Discussion in 'ASP .Net' started by =?Utf-8?B?bXIgZm94?=, May 16, 2005.

  1. You may be accessing the value before the viewstate has been loaded and
    control values updated from the form post. Try looking at the value in
    PreRender to check if this is the case.

    Regards,

    mr fox.

    "Sam C via .NET 247" wrote:

    > Hi,
    >
    > I have a really irritating problem with an ASP.NET page that I'm trying to get to work. It includes a DropDownList which I populate with ListItems in the Page_Load in cases where IsPostBack = False.
    >
    > When using any of the several methods to get the selected item in the DDL it always returns the first one in the DropDownList despite the fact that one of the other items may actually be selected. I've tried
    >
    > I've now made the page just write out the value of the DDL.SelectedItem as a debugging tool. The odd thing is that, if I resubmit the form it then starts to get the right value but, of course, it's the first time the form is submitted that I really need it to be right.
    >
    > I'd appreciate any help and can post any code that is needed. I see from other forum posts that some others have had the same problem but the only advice they get is to make sure the IsPostBack is used in an IF statement in Page_Load which I am doing.
    >
    > Thanks,
    >
    > Sam
    >
    > -----------------------
    > Posted by a user from .NET 247 (http://www.dotnet247.com/)
    >
    > <Id>m96oaRmQAkGDbrjEmcot9g==</Id>
    >
     
    =?Utf-8?B?bXIgZm94?=, May 16, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jesse
    Replies:
    3
    Views:
    1,269
    DudeGuy
    Jul 24, 2003
  2. Tom Jorgenson
    Replies:
    3
    Views:
    7,067
  3. Siamak Zahedi

    DropDownList always returning the first item

    Siamak Zahedi, Jan 27, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    805
    Karl Seguin
    Jan 28, 2005
  4. jobs
    Replies:
    0
    Views:
    504
  5. tconkling

    First statement always evaluated first?

    tconkling, Jul 9, 2005, in forum: C Programming
    Replies:
    3
    Views:
    356
    Keith Thompson
    Jul 9, 2005
Loading...

Share This Page