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. dropdownlist being ignored

dropdownlist being ignored

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netsysadminquestion
3 Posts 3 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.
  • M Offline
    M Offline
    mail572352
    wrote on last edited by
    #1

    Hi, I have a simple form with a textbox and a drop down list on it. I've used an ASP.NET (2.0) ddl control and an ASP.NET button for submitting the form. I have an event handler on the submit button, btnSubmit_Click() which triggers when the submit button is clicked. When I try and access the ddl's value in the event handler, it's always set to the original value it was when the page was loaded. In other words, it ignores whatever the user changes it too before clicking "Submit". Here's my aspx: <form id="frmTest" runat="server" action="test.aspx" method="post"> <asp:DropDownList ID="ddlColor" runat="server"> <asp:ListItem Value="Red">Red</asp:ListItem> <asp:ListItem Value="Amber">Amber</asp:ListItem> <asp:ListItem Value="Green">Green</asp:ListItem> </asp:DropDownList> <asp:button id="btnSubmit" text="Submit!" onClick="btnSubmit_Click" runat="server" /> Here's the code behind: protected void btnSubmit_Click(object sender, EventArgs e) { String str = ddlColor.SelectedItem.Text; } Do I need to call anything to get the changed value of the DDL before I look at the ddlColor.SelectedItem.Text property?

    S M 2 Replies Last reply
    0
    • M mail572352

      Hi, I have a simple form with a textbox and a drop down list on it. I've used an ASP.NET (2.0) ddl control and an ASP.NET button for submitting the form. I have an event handler on the submit button, btnSubmit_Click() which triggers when the submit button is clicked. When I try and access the ddl's value in the event handler, it's always set to the original value it was when the page was loaded. In other words, it ignores whatever the user changes it too before clicking "Submit". Here's my aspx: <form id="frmTest" runat="server" action="test.aspx" method="post"> <asp:DropDownList ID="ddlColor" runat="server"> <asp:ListItem Value="Red">Red</asp:ListItem> <asp:ListItem Value="Amber">Amber</asp:ListItem> <asp:ListItem Value="Green">Green</asp:ListItem> </asp:DropDownList> <asp:button id="btnSubmit" text="Submit!" onClick="btnSubmit_Click" runat="server" /> Here's the code behind: protected void btnSubmit_Click(object sender, EventArgs e) { String str = ddlColor.SelectedItem.Text; } Do I need to call anything to get the changed value of the DDL before I look at the ddlColor.SelectedItem.Text property?

      S Offline
      S Offline
      Sandeep Kumar
      wrote on last edited by
      #2

      Hi, No need to call anything to get the changed value of the DDL.

      1 Reply Last reply
      0
      • M mail572352

        Hi, I have a simple form with a textbox and a drop down list on it. I've used an ASP.NET (2.0) ddl control and an ASP.NET button for submitting the form. I have an event handler on the submit button, btnSubmit_Click() which triggers when the submit button is clicked. When I try and access the ddl's value in the event handler, it's always set to the original value it was when the page was loaded. In other words, it ignores whatever the user changes it too before clicking "Submit". Here's my aspx: <form id="frmTest" runat="server" action="test.aspx" method="post"> <asp:DropDownList ID="ddlColor" runat="server"> <asp:ListItem Value="Red">Red</asp:ListItem> <asp:ListItem Value="Amber">Amber</asp:ListItem> <asp:ListItem Value="Green">Green</asp:ListItem> </asp:DropDownList> <asp:button id="btnSubmit" text="Submit!" onClick="btnSubmit_Click" runat="server" /> Here's the code behind: protected void btnSubmit_Click(object sender, EventArgs e) { String str = ddlColor.SelectedItem.Text; } Do I need to call anything to get the changed value of the DDL before I look at the ddlColor.SelectedItem.Text property?

        M Offline
        M Offline
        Member 3879881
        wrote on last edited by
        #3

        Give if not page.ispostback then cmd...., or change the auto postback properties in ddl,

        Magesh

        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