I have following codes in asp.net:
<asp:dropdownlist id="ddlApp" runat="server" />
<asp:button id="btnSmt" runat="server" Text="Submit" />
and code behind:
private void btnSmt_Click(object sender, System.EventArgs e)
{
lbl.Text = ddlApp.SelectedItem.Value;
}
The logic is very simple. Get the selected value of dropdownlist and pass it to lbl.text.
But the problem is no matter how I try, the text show the fist value of list in the dropdownlist rather than the selected value.
And I notice that everytime I click the button the page refresh.
Please help.
BTW, I have the following event binding:
private void InitializeComponent()
{
this.btnSmt.Click += new System.EventHandler(this.btnSmt_Click);
this.Load += new System.EventHandler(this.Page_Load);
this.ddlApp.SelectedIndexChanged +=new System.EventHandler(this.ddlApp_Change);
}