In ASP.NET 2.0 and onwards things are much easier. The DropDownList control and other list controls now have a AppendDataBoundItems (7) property. With this property set to true, a call to DataBind leaves all existing items in the list. That allows you to add the extra items declaratively in the markup:
<asp:DropDownList ID="DropDownList1" runat="server"
AppendDataBoundItems="true">
<asp:ListItem Value="">Please select a country</asp:ListItem>
</asp:DropDownList>
That’s it. No more messing around with code in the code behind to add the item. Just set AppendDataBoundItems to true and the manually added item stays where it was.
Filed under: ASP.NET, Technology | Tagged: ASP.NET, Technology