O'Reilly logo

Programming ASP.NET, 3rd Edition by Dan Hurwitz, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

FormView Control: Examining Single Records as Master/Detail

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.

DetailsView and 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 AlternatingRowStyle property.)

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.

Drag a 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.

Data Source Configuration Wizard

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required