Q&A

Q1:In the examples using the DropDownList, I noticed that we have to set the DataTextField and DataValueField properties of the DropDownList to the names of fields in the DataSource. What happens if we forget to set these properties?
A1: In the “Binding Database Data to a DropDownList Web Control” section of this hour, we used a DropDownList to list the various customers from the Customers table. In this particular example, we set the DropDownList's DataTextField to Name and its DataValueField to CustomerID. This had the effect of having one list item in the DropDownList for each customer in the Customers table. The text of each list item was the value of the Name column in the Customers table, and the value associated with each list item ...

Get SAMS Teach Yourself ASP.NET in 24 Hours 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.