Saturday, 8 June 2019

C# - DropDownList - Get selected value in code behind


Watch this example on YouTube


1. HTML

   <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
        OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem> Test 1</asp:ListItem>
        <asp:ListItem> Test 2</asp:ListItem>
    </asp:DropDownList>

2. Code Behind

string selectedValue = DropDownList1.SelectedValue.ToString();

No comments:

Post a Comment