Archive for May 2008
DefaultDotAspx.com Is Launched…
DefaultDotAspx.com said “Hello world!” to the ASP.NET community.
What is it?
You can use DefaultDotAspx.com to get ready for the interviews or evaluate your knowledge. It is kind of a small knowledge base about ASP.NET and other topics. It has some short quizzes about ASP.NET and SQL as well.
There are tons of sites like this. So what?
Well… It is developed with the perspective of an ASP.NET development experience, therefore the content is dedicated accordingly. Even though it does not matter to the end-users, it was – and is being - developed by the latest version 3.5 and its new features.
Enhancing Paging in ListView by Using DataPager
DataPager is one of the new controls in ASP.NET 3.5, and it provides paging functionality for data-bound controls that implement the IPageableItemContainer interface, which is only the ListView control for the time being.
By default, DataPager has two commonly used paging styles:
• Numeric Pager via NumericPagerField
• Next and Previous Pager via NextPreviousPagerField
To get an idea about how to implement these basic common styles, you can read this post.
This post will explain how to enhance the paging experience in a ListView by using both a NextPreviousPagerField and a DropDownList which will enable users to select the page size of ListView. This page size is actually the PageSize property of the DataPager, and this property defines the number of records that are displayed for each page of ListView.
To avoid complexity, the following simple XML file (Contacts.xml) will be used as a data source:

And, the XMLDataSource that consumes this XML file is:

“xdsDemo” is the DataSourceID of the ListView “lvDemo”:

After getting this data binding done, LayoutTemplate of “lvDemo” should be similar to the following:

Even though it is not completely related with the topic and emphasis of this post, ItemTemplate and AltenatingItemTemplate templates of “lvDemo” are:

Finally, here is the code that sets DropDownList (ddlDemo) and DataPager (dpDemo):

As a conclusion of all these things, the result on the browser should be like:

Download
Sample code for this demo application can be downloaded via here.