Exploring new features of ListView
List view is a data bound control new on .net framework 3.5. In addition to display data on various styles it also supports add,edit,delete and paging functionality.
Requirements:
- Visual studio 2008 or Visual web developer 2008
- Dotnet framework 3.5
In this article you will be exploring the new features of ListView and Data pager controls of asp.net 3.5.
- Open the visual studio to get started with the tutorial. Create a new website. Here I m using the language C#.
- On the toolbox you will see extra two controls called ListView and Datapager (these controls are new to asp.net 3.5).

- Drag and drop the ListView control from the tool box to the designer surface of your aspx page. On the designer surface at the top right of the control click the task arrow button to open the quick task for the list view control as shown on the following picture. Bind the listview to the sqldatasource datasource control. Till here there is nothing new than the previous versions of data bound controls like grid view.
- Remember to configure the SqlDataSource for Insert, Update and Delete sql statements as well since we are using ListView to insert, update and deleting the records.

Now its time to configure the listview. On the tasks menu select Configure ListView.. . You can select the Layout, style and Options.

Layout: You can configure the listview to present on the data on different layouts like tablular format, on bulleted list etc. Here in this example I m using Bulleted List Layout option.
If you want more control over the layout and style of the results of your data, the best way to achieve is manually editing the templates of the listview on the aspx page itself.
Initially use the wizard to achieve the minimum work. Later go on editing on the aspx page and control the look and feel of your results.
Style: Different sets of colors and fonts style available here. It’s not recommended to use these styles on profession sites. You can define the template of the listview for advanced formatting.
Options: Here you can specify if you want Add/Edit/Delete/Paging support for the listview.
Now its time to dig into the aspx to more understand the list view control.
Below pics shows the templates that can be configured on the listview control.

Most of the templates are from the previous versions of data bound controls like repeater, datalist, gridview.
On Gridview there is no any option to control how the html tags are rendered on the browser. Now with listview you can control how the html tags are rendered on the browser. This gives you more flexibility to use listview controls. Even you can achieve div based layout for tabular results with listview controls that is still not possible with gridview. Gridview always generates results on table tags.
One extra template you can see on the listview is the layout template. Here you can define what type of layout you want to use. Table based layout, Div based layout , ul/li based layout. You have totally control of how your data will be rendered on the browser. This is the main advantage of listview.
How to define tags on Layout Template:
See the example of layout template to configure ul/li based layout.

Only one thing to take into account. You must create a control named itemplacehodler. This control is replaced by the rows.
See below examples.

Here is the final result displayed on the browser.







