Results 1 to 8 of 8

Thread: [RESOLVED] Drop Down Combo

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    Resolved [RESOLVED] Drop Down Combo

    So i'm fairly new to the web dev. been a forms programmer most of my career. I'm developing a web page. I have a drop down combo, and a button. When I click the button, I want to be able to get the selected text value of the combo. However, when I do this, it always gives me the first value and when the page "refreshes", the combo returns back to the first selected index.

    I'm sure this is a dumb question, but like i said i'm new to the WEB portion of VB.

    please help.

    thanks.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Drop Down Combo

    Thread moved and irrelevant posts deleted.

  3. #3
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Drop Down Combo

    Not much without your code but a guess:
    Use your code inside If Not Page.IsPostBack .
    If you press the button the page will do a partial refresh and if your code is outside the ispostback statement i will be re-executed thus recreating the combo.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    Re: Drop Down Combo

    I basically have a web page, with a drop down combo, and a button. When I click on the button, want to get the selectedindex of the combo and let's say put that value in a textbox already on the page.

    WHen I do this, I always get the value of 0 no matter which selection I choose from the drop down.

  5. #5
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Drop Down Combo

    yes that's true ,

    agreed with sapator
    because you Populate your DropDownList each time when your page is postback
    so you need to prevent it from being Populated at the first time.

    using
    Code:
    if(!IsPostBack){
    // here Populate your DropDownList
    }
    this will give you the solve to your Problem
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    Re: Drop Down Combo

    Thank You! I used it and is now working

  7. #7
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: [RESOLVED] Drop Down Combo

    ok, that's great
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Drop Down Combo

    Hello,

    The crux of the problem that you were having is with regard to the ASP.Net Page Life Cycle, which is very different to how things work in Windows Forms Applications.

    I would highly recommend that you take a look at the following:

    http://msdn.microsoft.com/en-us/library/ms178472.aspx

    And have a play with it. Set some breakpoints in each of the events that it mentions, and get a solid understanding on how it works.

    Any questions, feel free to ask.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width