In this article i show you how to declare dropdownlist different ways in asp.net
First we can declare in source code
1st way:-
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Text="Select State" Value="-1"></asp:ListItem>
<asp:ListItem Text="AP" Value="1"></asp:ListItem>
<asp:ListItem Text="UP" Value="2"></asp:ListItem>
<asp:ListItem Text="TS" Value="3"></asp:ListItem>
<asp:ListItem Text="MP" Value="4"></asp:ListItem>
<asp:ListItem Text="Tamilnadu" Value="5"></asp:ListItem>
</asp:DropDownList>
2nd way:-
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="-1">Select State</asp:ListItem>
<asp:ListItem Value="1">AP</asp:ListItem>
<asp:ListItem Value="2">UP</asp:ListItem>
<asp:ListItem Value="3">TS</asp:ListItem>
<asp:ListItem Value="4">MP</asp:ListItem>
<asp:ListItem Value="5">Tamilnadu</asp:ListItem>
</asp:DropDownList>
First we can declare in source code
1st way:-
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Text="Select State" Value="-1"></asp:ListItem>
<asp:ListItem Text="AP" Value="1"></asp:ListItem>
<asp:ListItem Text="UP" Value="2"></asp:ListItem>
<asp:ListItem Text="TS" Value="3"></asp:ListItem>
<asp:ListItem Text="MP" Value="4"></asp:ListItem>
<asp:ListItem Text="Tamilnadu" Value="5"></asp:ListItem>
</asp:DropDownList>
2nd way:-
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="-1">Select State</asp:ListItem>
<asp:ListItem Value="1">AP</asp:ListItem>
<asp:ListItem Value="2">UP</asp:ListItem>
<asp:ListItem Value="3">TS</asp:ListItem>
<asp:ListItem Value="4">MP</asp:ListItem>
<asp:ListItem Value="5">Tamilnadu</asp:ListItem>
</asp:DropDownList>