An alternative to the
DetailsView control is the
FormView control, which is built entirely with templates and, thus, gives you even greater control over the look and feel of the data.
FormView are derived from the
CompositeDataBoundControl class. Therefore, they share almost all the same properties, as listed in Table 9-8. (The only significant exception is that the
FormView does not have an
To demonstrate the
FormView, the next exercise will display details from the Products table, and will introduce the idea of navigating to a specific record based on the value chosen by a user from a drop down list of products.
Begin by adding a new page called Products to your web site.
DropDownList control from the Toolbox onto the page and give it an ID of
ddlProducts. Go to Design view. You’ll note that the smart tag opens. Choose New Data Source, and for this exercise, name the new data source
NorthWindProductsDataSource. You may use your existing connection, and choose the Product Name (to display) and the product ID (to identify which product was selected), as shown in Figure 9-28.
Figure 9-28. Data Source Configuration Wizard
Check Enable AutoPostBack in the smart tag or in the Properties window to ensure that when the user makes a selection in the drop down, the page is immediately ...