dropdownlist being ignored
-
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? -
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?Hi, No need to call anything to get the changed value of the DDL.
-
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?Give if not page.ispostback then cmd...., or change the auto postback properties in ddl,
Magesh