C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




PagedDataSource Class For Paging


Posted Date: 15 May 2008    Resource Type: Articles    Category: Web Applications
Author: Ramasamy.NMember Level: Gold    
Rating: Points: 10



PagedDataSource

We can use paging abilities to DataLists and Repeaters, even RadioButtonList and
CheckBoxList controls. It also encapsulates all the functionality of DataGrid’s
paging facility.



Its namespace is System.Web.UI.WebControls.


Constructor



PagedDataSource


Initializes a new instance of the PagedDataSource class.


Properties


AllowPaging – gets or sets a value indicates paging is enabled in a data-bound
control.


Syntax

public string AllowPaging {get; set; }


true if paging is enabled; otherwise, false.


AllowServerPaging


Gets or sets a value indicating whether server-side paging is enabled.


Syntax

public bool AllowServerPaging {get; set;}

true if server-side paging is enabled; otherwise, false;

ASP.NET version 2.0 data-bound controls (such as GridView, DetailsView, and
FormView) provide automatic paging functionality through server-side paging.
When using an ASP.NET 2.0 data-bound control, set this property to true.

Note:

Server-side paging and custom paging are mutually exclusive. If you set
AllowServerPaging to true, be sure that AllowCustomPaging is set to false.


Count

Gets the number of items to be used from the datasource


Syntax

public int Count { get;}

Use the Count property to determine the number of items to be used from the data
source. The value returned depends on whether paging is enabled and whether
custom paging is used.

• If paging is disabled (by setting the IsPagingEnabled property to
false), the value of the DataSourceCount property is returned.

• If paging is enabled (by setting the IsPagingEnabled property to true)
and custom paging is enabled (by setting the IsCustomPagingEnabled property set
to true), the value of the PageSize property is returned.

• If paging is enabled (by setting the IsPagingEnabled property to true)
and the IsLastPage property is set to false, the value of the PageSize property
is returned.

• If paging is enabled (by setting the IsPagingEnabled property to true),
custom paging is disabled (by setting the IsCustomPagingEnabled property false),
and the IsLastPage property is set to true, the value of the DataSourceCount
property is subtracted from the value of the FirstIndexInPage property before it
is returned.




• PageSize - This property takes an integer (by default it's set at 10),
and defines how many records are displayed on a page.

• AllowPaging - This property determines whether the paging should be
turned on or off (Boolean "true" or "false"). By default it's set to "false".

• CurrentPageIndex - This returns/sets the current page number. By default
it returns 0.

• PageCount - Returns a count of the total number of pages that are
available.

• DataSource - The value of this property will be the source of the data
you want to page.

• IsFirstPage - Returns "true" or "false", depending on whether the
current page is the first page in the series.

• IsLastPage - As above, but for the last page.


IsPagingEnabled
Gets a value indicating whether paging is enabled.
Syntax
public bool IsPagingEnabled {get; }
DataSourceCount
Gets the number of items in the Data Source;

OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/registration.mdb"));
conn.Open();
OleDbDataAdapter adpter = new OleDbDataAdapter("select * from students", conn);
DataSet data = new DataSet();
adpter.Fill(data);
PagedDataSource paging = new PagedDataSource();
paging.DataSource = data.Tables[0].DefaultView;
paging.AllowPaging = true;
paging.PageSize = 2;

paging.CurrentPageIndex =0;
Application["current"] = paging.CurrentPageIndex;
result.DataSource = paging;
result.DataBind();






Responses

Author: Mahesh Raj    07 Jun 2008Member Level: Gold   Points : 1
This is very good information,Continue posting such useful articles.


Author: John Fernandez    08 Jun 2008Member Level: Gold   Points : 1
Very well written Article.Thanks for sharing this information.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
PagedDataSource  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Google Search Macro
Previous Resource: RepeaterItem in the Repeater control
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use