TechBubbles Microsoft Technology BLOG

ASP.NET ListView control in VS 2008

Introduction

In this post I am going to explain the new data driven List view control that ships with Visual Studio 2008. To get start with the application create a web site in vs 2008.

1. Create a Web Site in Visual Studio 2008

2. Drag the ListView control from tool box under the Data section into the page.

ListView 

3. To populate the items in the ListView control we are using XML Datasource control. We can use any Datasource like object Datasource, SQL data Source or LINQ data source. 

Code

Configuring XML Data Source:

  • We are setting DataFile property of XML DataSource, in this case it is my BLOG RSS feed path.
  • We are specifying the items that we are going to display with the help of XPath property.
  • Now just we finished the configuring the XML datasource.

Configuring the ListView:

  • Specify the DataSource element where you want to pull the data in to ListView. In this case we have to give the XMLDataSource id.
  • Specify the ItemContainerId value as “DataSection”.

To configure this ListView we are using 3 Templates

  1. LayoutTemplate.
  2. ItemTemplate.
  3. ItemSeparatorTemplate.

LayoutTemplate is used to show the over all layout of the template. We can give the title for our page. We need to place a placeholder the id of this control specifically should be “itemPlaceholder”.

ItemTemplate is visual layout of the each item that we iterated over the each element inside the ListView Control. Specify the individual items that you want to display in the ListView.

ItemSeparatorTemplate is just specify the styles to separators in ListView items.

4. Run the above application we can see the result as shown in the following screen shot.

RSS

In the next I will explain about page control along with the ListView control.

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

2 Comments

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud