M5A B4N

Personal Blog of Mustafa Başgün

ListView Control in ASP.NET 3.5 – 2

with one comment

This post is actually a continuing demonstration of this one:

ListView Control in ASP.NET 3.5 – 1 (opens a new window)

It would be a better practice to jump into it first before reading this post.

EmptyDataTemplate

The empty template, EmptyDataTemplate, can be utilized to define the view when there is no data for the ListView, which means that the ListView control is bound to a DataSource having no records. In reality, this template is rendered instead of LayoutTemplate when ListView is empty. It renders by itself, therefore it is not required to be defined inside any other ListView templates.

I have defined the Select command of AccessDataSource1 in a way that it returns zero record, and put the empty template right after AlternatingItemTemplate between the ListView tags:

In order to hide the “Clear Sorting” and “View All” buttons when our ListView is empty, I will set their visibility values to False inside the Page_Load method when the DataSource (AccessDataSource1) has no records:

As a result of all these changes, the HTML presentation should look like:

It should also be known that…

Even though ListView is empty, EmptyDataTemplate can only be displayed when InsertItemPosition value is set to None (which is the default if the value is not defined). InsertItemPosition defines the location of InsertItemTemplate when it is rendered as a part of ListView.

Download

For further understanding of this post, you can download the source code (by VWD 2008) via here.

Update

This post is continued by:

ListView Control in ASP.NET 3.5 – 3
ListView Control in ASP.NET 3.5 – 4

About these ads

Written by Mustafa Başgün

December 28, 2007 at 5:00 PM

One Response

Subscribe to comments with RSS.

  1. [...] Mustafa Basgun también ha escrito algunos artículos sobre el nuevo control ListView. Leedlos 1, 2, 3, [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: