Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Listbox Dropdownlist SelectedIndex resets after postback. [modified]

Listbox Dropdownlist SelectedIndex resets after postback. [modified]

Scheduled Pinned Locked Moved ASP.NET
helpdatabasetutorialquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Junior Boy
    wrote on last edited by
    #1

    Hi all guys, I am trying to get the index of the listbox, after I selected RadioButton that has Autopostback=true. Here is some code..... string titleColor = this.titleColorList.Items[this.titleColorList.SelectedIndex].Text; And then I tried to show the result: Transparent The Transparent is the first member of list or it has index=0 It took me for hours :( still don't know how to get it work. Anybody know how to resolve this problem? Any help would be appreciated. Thank you very much. -- modified at 6:02 Friday 15th June, 2007

    junior boy

    P V 2 Replies Last reply
    0
    • J Junior Boy

      Hi all guys, I am trying to get the index of the listbox, after I selected RadioButton that has Autopostback=true. Here is some code..... string titleColor = this.titleColorList.Items[this.titleColorList.SelectedIndex].Text; And then I tried to show the result: Transparent The Transparent is the first member of list or it has index=0 It took me for hours :( still don't know how to get it work. Anybody know how to resolve this problem? Any help would be appreciated. Thank you very much. -- modified at 6:02 Friday 15th June, 2007

      junior boy

      P Offline
      P Offline
      Pierre147
      wrote on last edited by
      #2

      set EnableViewState of your dropdownlist to true, it will save the value after the page load. If it is not what you need, I did not well understood

      J 1 Reply Last reply
      0
      • P Pierre147

        set EnableViewState of your dropdownlist to true, it will save the value after the page load. If it is not what you need, I did not well understood

        J Offline
        J Offline
        Junior Boy
        wrote on last edited by
        #3

        The listbox dropdownlist still keep and showing what member I selected after postback but when I tried to show what exactly selectedIndex is, it shows me the first index, it wasn't the index of the selected value. Regard,

        junior boy

        P G 2 Replies Last reply
        0
        • J Junior Boy

          The listbox dropdownlist still keep and showing what member I selected after postback but when I tried to show what exactly selectedIndex is, it shows me the first index, it wasn't the index of the selected value. Regard,

          junior boy

          P Offline
          P Offline
          Pierre147
          wrote on last edited by
          #4

          why you don't do just this? string titleColor = this.titleColorList.SelectedValue;

          1 Reply Last reply
          0
          • J Junior Boy

            The listbox dropdownlist still keep and showing what member I selected after postback but when I tried to show what exactly selectedIndex is, it shows me the first index, it wasn't the index of the selected value. Regard,

            junior boy

            G Offline
            G Offline
            goutham sriharsha
            wrote on last edited by
            #5

            Hi, Try this In page load try to use if(!page.Ispostback) and inside it try to keep the your code ...it may work.....

            Goutham

            J 1 Reply Last reply
            0
            • G goutham sriharsha

              Hi, Try this In page load try to use if(!page.Ispostback) and inside it try to keep the your code ...it may work.....

              Goutham

              J Offline
              J Offline
              Junior Boy
              wrote on last edited by
              #6

              Thank you very sir, Not I got it worked:) Actually I have tried to use SelecteValue but I didn't get it work somehow but now I tried it again and it work well. Thank you very much and really appreciated.

              junior boy

              1 Reply Last reply
              0
              • J Junior Boy

                Hi all guys, I am trying to get the index of the listbox, after I selected RadioButton that has Autopostback=true. Here is some code..... string titleColor = this.titleColorList.Items[this.titleColorList.SelectedIndex].Text; And then I tried to show the result: Transparent The Transparent is the first member of list or it has index=0 It took me for hours :( still don't know how to get it work. Anybody know how to resolve this problem? Any help would be appreciated. Thank you very much. -- modified at 6:02 Friday 15th June, 2007

                junior boy

                V Offline
                V Offline
                Vasudevan Deepak Kumar
                wrote on last edited by
                #7

                It looks like the dropdownlist is getting rebound in Page_Load even on Postback. Can you check whether you could bypass this by using IsPostback property so that the control is resurrected of its values from the ViewState statebag?

                Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups