Chapter 10Displaying Content Using Data Lists

Similar to the Repeater control, the DataList control allows you to bind and customize the presentation of database data. The fundamental difference is that while the Repeater requires building the template from scratch (allowing you to customize the generated HTML output in any way you like), the DataList control automatically generates a single-column HTML table for you, like the one shown below:

<table> <tr> <td> <p>Employee ID: 1</p> <p>Name: Zak Ruvalcaba</p> <p>Username: zak</p> </td> </tr> <tr> <td> <p>Employee ID: 2</p> <p>Name: Jessica Ruvalcaba</p> <p>Username: jessica</p> </td> </tr> <tr> <td> <p>Employee ID: 3</p> <p>Name: Ted Lindsey</p> <p>Username: ted</p> </td> </tr> … </table> ...

Get Build Your Own ASP.NET 4 Web Site Using C# & VB, 4th Edition 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.