27 February 2014

Add Default Item In DropDownList

              I have a dropdown list that takes it's values (country name) from a database. But what I would like to be able to do is to set the first item in the dropdown list manully.
· Add DropDownList in your .aspx page
<asp:dropdownlist id="DropDownList1" runat="server">
<asp:listitem value="Select Country">---Select Country---</asp:ListItem>
</asp:DropDownList>
· Now set the AppendDataBoundItems Property of dropdownlist to true
<asp:dropdownlist id="DropDownList1" runat="server" appenddatabounditems="True">
<asp:listitem value="Select Country">---Select Country--</asp:ListItem>
</asp:DropDownList>

No comments:

Post a Comment