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. Event Fire in Drop Down List

Event Fire in Drop Down List

Scheduled Pinned Locked Moved ASP.NET
help
15 Posts 7 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.
  • R Rinki Mukheraji

    Please Everybody help me. I had been send this problem before two hour. Enter the value in dropdownlist. page_load() { dropdownlist1.items.insert(0,new listitem("Add New","0") } dropdownlist1_selectedIndexchanged() { if(dropdownlist1.selectedindex == 0) { responce.write("Asdf"); } } But not fired this event.

    C Offline
    C Offline
    codeproject_Tarun
    wrote on last edited by
    #3

    Perhaps u forget two things 1.To Write the below line with in if clause having page ispostback conditon. dropdownlist1.items.insert(0,new listitem("Add New","0") and 2. set the Autopostback property of dropdownlist to True. hope it helps U. Regards Tarun Singh Sr. Software Engineer. mailto:tksingh@zenta.com

    R 1 Reply Last reply
    0
    • R Rinki Mukheraji

      Please Everybody help me. I had been send this problem before two hour. Enter the value in dropdownlist. page_load() { dropdownlist1.items.insert(0,new listitem("Add New","0") } dropdownlist1_selectedIndexchanged() { if(dropdownlist1.selectedindex == 0) { responce.write("Asdf"); } } But not fired this event.

      S Offline
      S Offline
      Sandeep Akhare
      wrote on last edited by
      #4

      Because by default this item is selected i.e first item in Drop down is always selected

      Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

      1 Reply Last reply
      0
      • R Rinki Mukheraji

        Please Everybody help me. I had been send this problem before two hour. Enter the value in dropdownlist. page_load() { dropdownlist1.items.insert(0,new listitem("Add New","0") } dropdownlist1_selectedIndexchanged() { if(dropdownlist1.selectedindex == 0) { responce.write("Asdf"); } } But not fired this event.

        J Offline
        J Offline
        John ph
        wrote on last edited by
        #5

        Here is a piece of code that works fine in my system. just check with this you are doing it right... HTML ----- <-asp:dropdownlist id="DropDownList1" runat="server" 0nSelectedIndexChanged="dropdownlist_SelectedIndexChanged" AutoPostBack="True"> Code-Behind ------------ private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { DropDownList1.Items.Insert(0, new ListItem("First", "1")); DropDownList1.Items.Insert(1, new ListItem("Second", "2")); DropDownList1.Items.Insert(2, new ListItem("Third", "3")); } } public void dropdownlist_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.Text = DropDownList1.SelectedItem.Text; } Note: SelectedIndexChanged event will fire only when you change the dropdown item.

        Regards
         - J O H N -


        R 1 Reply Last reply
        0
        • R Rinki Mukheraji

          Please Everybody help me. I had been send this problem before two hour. Enter the value in dropdownlist. page_load() { dropdownlist1.items.insert(0,new listitem("Add New","0") } dropdownlist1_selectedIndexchanged() { if(dropdownlist1.selectedindex == 0) { responce.write("Asdf"); } } But not fired this event.

          M Offline
          M Offline
          Mogha Ritesh
          wrote on last edited by
          #6

          Please add this item as follow : dropdownlist1.items.add("abcd"); then write this code of selectedindexchanged event as follow: int index=dropdownlist1.selectedindex(); // to confirm the desired index number pls write this code Response.write(index.tostring()); if(index==0) { Response.Write("Asdf"); } Ritesh Mogha

          R 1 Reply Last reply
          0
          • C codeproject_Tarun

            Perhaps u forget two things 1.To Write the below line with in if clause having page ispostback conditon. dropdownlist1.items.insert(0,new listitem("Add New","0") and 2. set the Autopostback property of dropdownlist to True. hope it helps U. Regards Tarun Singh Sr. Software Engineer. mailto:tksingh@zenta.com

            R Offline
            R Offline
            Rinki Mukheraji
            wrote on last edited by
            #7

            AutoPostBack Property is already true.

            S 1 Reply Last reply
            0
            • R Rinki Mukheraji

              AutoPostBack Property is already true.

              S Offline
              S Offline
              Sandeep Akhare
              wrote on last edited by
              #8

              Gagan Deep Garg wrote:

              '07 AutoPostBack Property is already true.

              i didn't say anything about this :~ See that event will fire only when selected Index changed as it is in name. And by default first item is selected so it will not fire untill you select another item

              Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

              1 Reply Last reply
              0
              • J John ph

                Here is a piece of code that works fine in my system. just check with this you are doing it right... HTML ----- <-asp:dropdownlist id="DropDownList1" runat="server" 0nSelectedIndexChanged="dropdownlist_SelectedIndexChanged" AutoPostBack="True"> Code-Behind ------------ private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { DropDownList1.Items.Insert(0, new ListItem("First", "1")); DropDownList1.Items.Insert(1, new ListItem("Second", "2")); DropDownList1.Items.Insert(2, new ListItem("Third", "3")); } } public void dropdownlist_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.Text = DropDownList1.SelectedItem.Text; } Note: SelectedIndexChanged event will fire only when you change the dropdown item.

                Regards
                 - J O H N -


                R Offline
                R Offline
                Rinki Mukheraji
                wrote on last edited by
                #9

                yes I check at this lines.

                R 1 Reply Last reply
                0
                • M Mogha Ritesh

                  Please add this item as follow : dropdownlist1.items.add("abcd"); then write this code of selectedindexchanged event as follow: int index=dropdownlist1.selectedindex(); // to confirm the desired index number pls write this code Response.write(index.tostring()); if(index==0) { Response.Write("Asdf"); } Ritesh Mogha

                  R Offline
                  R Offline
                  Rinki Mukheraji
                  wrote on last edited by
                  #10

                  No Go To My Pointer

                  1 Reply Last reply
                  0
                  • R Rinki Mukheraji

                    yes I check at this lines.

                    R Offline
                    R Offline
                    Rinki Mukheraji
                    wrote on last edited by
                    #11

                    No Go To My Pointer this function

                    J 1 Reply Last reply
                    0
                    • R Rinki Mukheraji

                      No Go To My Pointer this function

                      J Offline
                      J Offline
                      John ph
                      wrote on last edited by
                      #12

                      Gagan Deep Garg wrote:

                      No Go To My Pointer this function

                      what do you mean?

                      Regards
                       - J O H N -


                      R 1 Reply Last reply
                      0
                      • J John ph

                        Gagan Deep Garg wrote:

                        No Go To My Pointer this function

                        what do you mean?

                        Regards
                         - J O H N -


                        R Offline
                        R Offline
                        Rinki Mukheraji
                        wrote on last edited by
                        #13

                        set the Debug pointer not go to debug pointer in this function.

                        J 1 Reply Last reply
                        0
                        • R Rinki Mukheraji

                          Please Everybody help me. I had been send this problem before two hour. Enter the value in dropdownlist. page_load() { dropdownlist1.items.insert(0,new listitem("Add New","0") } dropdownlist1_selectedIndexchanged() { if(dropdownlist1.selectedindex == 0) { responce.write("Asdf"); } } But not fired this event.

                          A Offline
                          A Offline
                          Ahmad Adnan
                          wrote on last edited by
                          #14

                          set AutoPostBack to true in the DropDownList

                          1 Reply Last reply
                          0
                          • R Rinki Mukheraji

                            set the Debug pointer not go to debug pointer in this function.

                            J Offline
                            J Offline
                            John ph
                            wrote on last edited by
                            #15

                            I don't get exactly what you are saying?

                            Regards
                             - J O H N -


                            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