A.12. Chapter 12
A.12.1.
A.12.1.1.
A.12.1.1.1. Exercise 1 solution
The best control for this scenario is GridView. It's easy to set up and has built-in support for paging, updating, and deleting of data. Together with a DetailsView control you can offer your users all four CRUD operations. In addition, you need a SqlDataSource control to get the data from the database and display it in the GridView or DetailsView.
A.12.1.1.2. Exercise 2 solution
For a simple, unordered list, you're probably best off using a Repeater control. The biggest benefit of the Repeater control is that it emits no HTML code on its own, allowing you to control the final markup. A downside of the control is that it doesn't support editing or deletion of data, which isn't a problem if all you need to do is present the data in a list. Chapter 13 shows you how to use the Repeater control.
A.12.1.1.3. Exercise 3 solution
A BoundField is directly tied to a column in your data source and offers only limited ways to customize its appearance. The TemplateField, on the other hand, gives you full control over the way the field is rendered. As such, it's an ideal field for more complex scenarios — for example, when you want to add validation controls to the page, or if you want to let the user work with a different control, like a DropDownList instead of the default TextBox.
A.12.1.1.4. Exercise 4 solution
You should always store your connection strings in the web.config file. This file has an element called ...