Appending Data Items
You can mix the list items that you declare in a List control and the list items that are added to the control when it is bound to a data source. This is useful when you want to display a default selection.
For example, imagine that you create a form in which you want to require a user to pick an item from a List control. In this situation, you should add a default item to the List control so that you can detect whether a user has actually picked an item.
You can mix declarative list items with databound list items by assigning the value True
to the AppendDataBoundItems
property. The page in Listing 10.6 illustrates how you can add a default list item to a List control (see Figure 10.6).
Figure 10.6. Displaying a default ...
Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.