Data binding is a really handy way to fill list controls with values from some data source - usually a database, but it can come from almost anywhere. However, there are times when you may want your list box to have some additional items - maybe an instructional message - "Please pick a value..." or an "All" option.
So - just a quick reminder that you can do this very very easily in ASP.NET.
<asp:DropDownList ID="cboCountry" runat="server" Width="250px" DataTextField="CountryName" DataValueField="CountryId" AppendDataBoundItems="true"> <asp:ListItem Value="-1">All</asp:ListItem></asp:DropDownList>
Just set AppendDataBoundItems to true, and add in your other values as asp:ListItem entries. In my case the drop down list allows the user to filter data by country. But I also needed a way to have them remove a country filter - i.e. show all the data again. Thus the "All" option, and the -1 value.
I'm Dave and this is my blog. I'm usually writing about .NET Software Development, ArcGIS, or Agile Practices, but other stuff does creep in from time to time. I hope you find something of use, and feel free to contact me if you have any questions. You can also check out my profile on LinkedIn
dojo.DTSAgile.com is our technology preview / demo site. As I and my team cook up cool things we post them here.
ArcDeveloper.net is a site that hosts a set of open source projects related to ArcGIS. This includes Tile Cache for .NET (TC4N) and Feature Server for .NET (FS4N). Come over and check it out!
Assembla is a free service that provides Subversion source control, wikis and work Tracking. The ArcDeveloper project is run from here. It rocks. Check them out today.
Agilistas is a LinkedIn group focused on discussing and promoting Agile practices. Everyone is welcome to join in the conversation as we evolve the process of creating software to make it more enjoyable for all involved.