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 selected items into an array

listbox selected items into an array

Scheduled Pinned Locked Moved ASP.NET
databasedata-structureshelp
5 Posts 5 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.
  • B Offline
    B Offline
    Bharani_Ram
    wrote on last edited by
    #1

    The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.

    Bharani

    A P V S 4 Replies Last reply
    0
    • B Bharani_Ram

      The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.

      Bharani

      A Offline
      A Offline
      Ashwini K Singh
      wrote on last edited by
      #2

      Can you please explain what exactly you want i thing you need previous selection and changed selection both for some comparisation

      1 Reply Last reply
      0
      • B Bharani_Ram

        The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.

        Bharani

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Member 4463285 wrote:

        please its urgent

        That is a very rude and impolite approach at getting help on this site.

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        1 Reply Last reply
        0
        • B Bharani_Ram

          The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.

          Bharani

          V Offline
          V Offline
          Venkatesh Mookkan
          wrote on last edited by
          #4

          Try this,

          protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
          {
          _count++;
          _items = new string[_count];
          
          if (Session["Items"]!=null)
          {
          _items = Session["Items"];
          }
          
          _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); 
          
          Session["Items"] = _items;
          
          }
          

          Normal variable's values will be clear once the response is done. You can use Static variables but Static variable would share the values to other users also. But use a Session variable to maintain the items.

          Castle Rider My: Website | Yahoo Group | Blog Spot

          1 Reply Last reply
          0
          • B Bharani_Ram

            The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.

            Bharani

            S Offline
            S Offline
            Sherin Iranimose
            wrote on last edited by
            #5

            Member 4463285 wrote:

            _items = new string[_count];

            This may be cause of the problem. Every time you are initializing the array.So all items automatically erased.

            EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE. How to post a question

            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