Next, add the following five ASP.NET pages to this folder, having all of them configured to use the master page Site.master:įigure 1: Create a DataListRepeaterBasics Folder and Add the Tutorial ASP.NET Pages Start by creating a new folder in the project named DataListRepeaterBasics. Step 1: Adding the DataList and Repeater Tutorial Web Pagesīefore we start this tutorial, let s first take a moment to add the ASP.NET pages we'll need for this tutorial and the next few tutorials dealing with displaying data using the DataList and Repeater.
We'll see how to format these controls, how to alter the layout of data source records in the DataList, common master/details scenarios, ways to edit and delete data, how to page through records, and so on. Over the next dozen or so tutorials, we'll look at building common reporting patterns with the DataList and Repeater controls, starting with the basics of displaying data with these controls templates. The Repeater, on the other hand, renders no additional markup than what you explicitly specify, and is an ideal candidate when you need precise control over the markup emitted. Like the GridView, the DataList renders as an HTML, but allows for multiple data source records to be displayed per table row. The DataList and Repeater controls render their content using templates rather than BoundFields, CheckBoxFields, ButtonFields, and so on. To provide a greater degree of customization in the appearance and rendered markup when displaying multiple records, ASP.NET 2.0 offers the DataList and Repeater controls (both of which were also available in ASP.NET version 1.x). Moreover, the markup responsible for the GridView s structure is fixed it includes an HTML with a table row ( ) for each record and a table cell ( ) for each field. While the GridView makes it a snap to display, page through, sort, edit, and delete data, its appearance is a bit boxy. The GridView renders a row for each record in the data source, displaying the record s data fields in columns. In all of the examples throughout the past 28 tutorials, if we needed to display multiple records from a data source we turned to the GridView control. Starting with this tutorial, we look at building common reporting patterns with the DataList and Repeater controls, starting with the basics of displaying data with these controls. In the preceding tutorials we have used the GridView control to display data.