473,394 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Custom Paging in ASP.NET

Hello friends, i am designing a ASP.NET page where i want to use custom
paging bcoz data is too heavy so pls tell me how can i use custom paging in
ASP.NET
Thanks
Nov 19 '05 #1
2 2198
http://www.dotnetjunkies.com/Tutoria...B871F967F.dcik

"asad" <as**@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
Hello friends, i am designing a ASP.NET page where i want to use custom
paging bcoz data is too heavy so pls tell me how can i use custom paging
in
ASP.NET
Thanks


Nov 19 '05 #2
The ASP.NET DataGrid exposes a wonderful capability: data paging support.
When paging is enabled in the DataGrid, a fixed number of records is shown at
a time. Additionally, paging UI is also shown at the bottom of the DataGrid
for navigating through the records. The paging UI allows you to navigate
backwards and forwards through displayed data, displaying a fixed number of
records at a time.

There's one slight wrinkle. Paging with the DataGrid requires all of the
data to be bound to the grid. For example, your data layer will need to
return all of the data and then the DataGrid will filter all the displayed
records based on the current page. If 100,000 records are returned when
you're paging through the DataGrid, 99,975 records would be discarded on each
request (assuming a page size of 25). As the number of records grows, the
performance of the application will suffer as more and more data must be sent
on each request.

One good approach to writing better paging code is to use stored procedures.
Following Query shows a sample stored procedure that pages through the Orders
table in the Northwind database. In a nutshell, all you're doing here is
passing in the page index and the page size. The appropriate resultset is
calculated and then returned.

CREATE PROCEDURE northwind_OrdersPaged
(
@PageIndex int,
@PageSize int
)
AS
BEGIN
DECLARE @PageLowerBound int
DECLARE @PageUpperBound int
DECLARE @RowsToReturn int

-- First set the rowcount
SET @RowsToReturn = @PageSize * (@PageIndex + 1)
SET ROWCOUNT @RowsToReturn

-- Set the page bounds
SET @PageLowerBound = @PageSize * @PageIndex
SET @PageUpperBound = @PageLowerBound + @PageSize + 1

-- Create a temp table to store the select results
CREATE TABLE #PageIndex
(
IndexId int IDENTITY (1, 1) NOT NULL,
OrderID int
)

-- Insert into the temp table
INSERT INTO #PageIndex (OrderID)
SELECT
OrderID
FROM
Orders
ORDER BY
OrderID DESC

-- Return total count
SELECT COUNT(OrderID) FROM Orders

-- Return paged results
SELECT
O.*
FROM
Orders O,
#PageIndex PageIndex
WHERE
O.OrderID = PageIndex.OrderID AND
PageIndex.IndexID > @PageLowerBound AND
PageIndex.IndexID < @PageUpperBound
ORDER BY
PageIndex.IndexID

END

The total number of records returned can vary depending on the query being
executed. For example, a WHERE clause can be used to constrain the data
returned. The total number of records to be returned must be known in order
to calculate the total pages to be displayed in the paging UI. For example,
if there are 1,000,000 total records and a WHERE clause is used that filters
this to 1,000 records, the paging logic needs to be aware of the total number
of records to properly render the paging UI.

thanx,
Smith
"Ken Cox [Microsoft MVP]" wrote:
http://www.dotnetjunkies.com/Tutoria...B871F967F.dcik

"asad" <as**@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
Hello friends, i am designing a ASP.NET page where i want to use custom
paging bcoz data is too heavy so pls tell me how can i use custom paging
in
ASP.NET
Thanks


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephen | last post by:
This is a real brain-teaser and i'd really appreciate it if someone can try and understand what im trying to do and give me a few pointers or ideas to help me work out my problem. Im basically...
2
by: Maziar Aflatoun | last post by:
Hi, I'm having problems with Custom Paging. Most of the articles out there show that the custom paging is done as the following article. ...
3
by: Clint | last post by:
Hi, I am trying to implement the custom paging in the datalist in this format: << Prev 1,2,3,4,5 Next >>. Does anyone knows how to do this. Thanks in advance. Clint
0
by: asad | last post by:
Hello, i want to do Custom paging i'm using MS Access Database when i'm using SQL SERVER Database Custom paging work ok but when i'm using MS Access Database it does not work pls tell me how can i...
1
by: thechaosengine | last post by:
Hi all, Can somebody tell me if the built in paging support for the datagrid works when using a custom collection and a custom business object as the data. I was well pleased when I found that...
2
by: asad | last post by:
hello friends, how ru all I want to create a custom paging logic in ASP.NET with a next link for example if i have 100 pages record so i want to show 6 pages link on page one and next link ...
3
by: Sachin | last post by:
Hi All, I am using ASP.NET 2.0 Tree control to display hierarachical data. However because of the size of the data, tree takes ages to load on the browser. For that reason, I want to build...
0
by: Roy | last post by:
Hey all, I must be losing my touch. I have made many pages in the 1.1 framework that utilize custom bidirectional paging in datagrids. We've converted over to 2.0 and I've been trying to use the...
7
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
The default paging behavior of the gridview doesn't work well with very large sets of data which means we have to implement some sort of custom paging. The examples I have seen (4guysfromrolla,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.