Search code examples
c#drop-down-menuvisual-web-developer

Dropdownlist to label output C#


I want to show different labels output from DropDownList with button

select Item on DropDownList and click button to show output in label

Can anyone help me out on this?


Solution

  • protected void Button1_Click(object sender, EventArgs e)
    {
        lable1.Text=DropDownList1.SelectedValue.ToString();
    }
    

    or u can do

       protected void Button1_Click(object sender, EventArgs e)
       {
           String input=DropDownList1.SelectedIndex >= 0 ? DropDownList1.SelectedItem.ToString() : "";
           lable1.Text=input;
       }