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. General Programming
  3. C#
  4. ListBox Event

ListBox Event

Scheduled Pinned Locked Moved C#
databasehelpquestion
3 Posts 2 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.
  • S Offline
    S Offline
    Sean89
    wrote on last edited by
    #1

    I have two listboxes on a webform. One has a list of groups in it, and the other will have the members of the group depending on what index is selected in the group listbox. I am handeling the SelectedIndexChanged event of the Group list box so that I can change the contents of the second listbox. The problem is that the event doesn't seem to be firing:

    protected void GroupList\_SelectedIndexChanged1(object sender, EventArgs e)
    {
        //get what group has been selected
        int index = GroupList.SelectedIndex;
    
        // get all the mounts in the group
        DataRow\[\] rows = dSet.Tables\["Mounts"\].Select("Group\_Number =" + GroupList.Items\[index\].Text);
    
        // Clear the previous mount list
        foreach (ListItem item in MountList.Items)
        {
            MountList.Items.Remove(item);
        }
    
        //Display the mounts in the group
        foreach (DataRow row in rows)
        {
            MountList.Items.Add(row\[0\].ToString());
        }   
    }
    

    Any Ideas? Thanks for any responses ;)


    L 1 Reply Last reply
    0
    • S Sean89

      I have two listboxes on a webform. One has a list of groups in it, and the other will have the members of the group depending on what index is selected in the group listbox. I am handeling the SelectedIndexChanged event of the Group list box so that I can change the contents of the second listbox. The problem is that the event doesn't seem to be firing:

      protected void GroupList\_SelectedIndexChanged1(object sender, EventArgs e)
      {
          //get what group has been selected
          int index = GroupList.SelectedIndex;
      
          // get all the mounts in the group
          DataRow\[\] rows = dSet.Tables\["Mounts"\].Select("Group\_Number =" + GroupList.Items\[index\].Text);
      
          // Clear the previous mount list
          foreach (ListItem item in MountList.Items)
          {
              MountList.Items.Remove(item);
          }
      
          //Display the mounts in the group
          foreach (DataRow row in rows)
          {
              MountList.Items.Add(row\[0\].ToString());
          }   
      }
      

      Any Ideas? Thanks for any responses ;)


      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Why aren't you using DataBinding?

      Sean89 wrote:

      The problem is that the event doesn't seem to be firing:

      "Seem to be" does not help. It either does or does not, which is it? If it is not firing then something is not set correctly.


      "What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum led mike

      S 1 Reply Last reply
      0
      • L led mike

        Why aren't you using DataBinding?

        Sean89 wrote:

        The problem is that the event doesn't seem to be firing:

        "Seem to be" does not help. It either does or does not, which is it? If it is not firing then something is not set correctly.


        "What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum led mike

        S Offline
        S Offline
        Sean89
        wrote on last edited by
        #3

        led mike wrote:

        If it is not firing then something is not set correctly.

        I thought about that for a second then I realized that I didn't have AutoPostBack set to true for the control. Works fine now :laugh: Thanks for the heads up!


        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