473,400 Members | 2,163 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,400 software developers and data experts.

ASP.NET:: Paging on Demand

Info::
Most of you must have worked on paging feature of DataGrid. its works fine as long as you have more no of records to show, but if you have configured 20 records per page and no of records you retrieved is less then 20 then also pager gets rendered at the bottom of the grid showing "1". most of us do not bother about it , but Clients ,,,uff...

Solution:
SQLDataAdapter.Fill(DS,"Emp")

If DS.Tables("Emp").Rows.Count > MyDataGrid1.PageSize then
MyDataGrid1.AllowPaging = True
Else
MyDataGrid1.AllowPaging = False
End if

MyDataGrid1.DataBind()

Any better ways?

ya perhaps this could have been reduced to one line also eg.

MyDataGrid1.AllowPaging = ( DS.Tables("Emp").Rows.Count > MyDataGrid1.PageSize )

Anything better then this?

Regards
Jignesh Desai
www.dotnetjini.com

Jan 24 '06 #1
2 1371
Agreed, but you can also extend this paging template with a checkbox to disable it.
I did a similar thing but outside the grid.

"Jignesh Desai" <ji***********@hotmail.com> schreef in bericht news:es**************@TK2MSFTNGP12.phx.gbl...
Info::
Most of you must have worked on paging feature of DataGrid. its works fine as long as you have more no of records to show, but if you have configured 20 records per page and no of records you retrieved is less then 20 then also pager gets rendered at the bottom of the grid showing "1". most of us do not bother about it , but Clients ,,,uff...

Solution:
SQLDataAdapter.Fill(DS,"Emp")

If DS.Tables("Emp").Rows.Count > MyDataGrid1.PageSize then
MyDataGrid1.AllowPaging = True
Else
MyDataGrid1.AllowPaging = False
End if

MyDataGrid1.DataBind()

Any better ways?

ya perhaps this could have been reduced to one line also eg.

MyDataGrid1.AllowPaging = ( DS.Tables("Emp").Rows.Count > MyDataGrid1.PageSize )

Anything better then this?

Regards
Jignesh Desai
www.dotnetjini.com

Jan 24 '06 #2
Hi Jignesh,

Another means is use the DataGrid's PreRender event and set the
DataGrid.PagerStyle.Visible according to its current page count. e.g:

protected void dgPage_PreRender(object sender, EventArgs e)
{
if (dgPage.PageCount == 1)
{
dgPage.PagerStyle.Visible = false;
}
}
This can make our code just specific to the DataGrid without put in some
other page wide event.....

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "Edwin Knoppert" <in**@pbsoft.speedlinq.nl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Re: ASP.NET:: Paging on Demand
| Date: Tue, 24 Jan 2006 22:11:50 +0100
| Organization: QinIP
| Lines: 117
| Message-ID: <dr**********@azure.qinip.net>
| References: <es**************@TK2MSFTNGP12.phx.gbl>
| NNTP-Posting-Host: h8441197235.dsl.speedlinq.nl
| Mime-Version: 1.0
| Content-Type: multipart/alternative;
| boundary="----=_NextPart_000_0016_01C62133.2D11FC80"
| X-Trace: azure.qinip.net 1138137108 8548 84.41.197.235 (24 Jan 2006
21:11:48 GMT)
| X-Complaints-To: ab***@qinip.net
| NNTP-Posting-Date: Tue, 24 Jan 2006 21:11:48 +0000 (UTC)
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-onli
ne.de!newsfeed.freenet.de!213.132.189.2.MISMATCH!m ultikabel.net!feed20.multi
kabel.net!news2.euro.net!azure.qinip.net!not-for-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:373273
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Agreed, but you can also extend this paging template with a checkbox to
disable it.
| I did a similar thing but outside the grid.
| "Jignesh Desai" <ji***********@hotmail.com> schreef in bericht
news:es**************@TK2MSFTNGP12.phx.gbl...
| Info::
| Most of you must have worked on paging feature of DataGrid. its works
fine as long as you have more no of records to show, but if you have
configured 20 records per page and no of records you retrieved is less then
20 then also pager gets rendered at the bottom of the grid showing "1".
most of us do not bother about it , but Clients ,,,uff...
| Solution:
| SQLDataAdapter.Fill(DS,"Emp")
| If DS.Tables("Emp").Rows.Count > MyDataGrid1.PageSize then
| MyDataGrid1.AllowPaging = True
| Else
| MyDataGrid1.AllowPaging = False
| End if
| MyDataGrid1.DataBind()
| Any better ways?
| ya perhaps this could have been reduced to one line also eg.
| MyDataGrid1.AllowPaging = ( DS.Tables("Emp").Rows.Count >
MyDataGrid1.PageSize )
| Anything better then this?
| Regards
| Jignesh Desai
| www.dotnetjini.com
|

Jan 25 '06 #3

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

Similar topics

3
by: Kenneth | last post by:
Hi, I have an asp.net app that users would like to print out on paper, but the items in the grid are sometimes more than the height of the paper so the grid is divided onto several pages. I...
1
by: Danny Ni | last post by:
Hi, We use ASP.Net datagrid paging a lot and we have been experiencing "Index out of bound" error messages when we click on rows of datagrid on differnet pages every now and then. The...
2
by: asad | last post by:
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
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 ...
22
by: Zen | last post by:
Hi, My production machine has 2G of memory, when aspnet_wp.exe goes up to about ~1.2G of memory usage, I start get out-of-memory exception. Other processes don't use as much memory and I added...
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...
2
by: Daniel Di Vita | last post by:
I have created an ASP.NET page that allows the user to page through a result set. I need to expand on this. On that same page I a filed where the user can type in a search string. When they click...
2
by: farhad13841384 | last post by:
Hi , I Hope You fine. I have some problem with this code for paging in asp.net this bottom code work correctly without any error but when I try to place separate code in .VB file then error is...
11
by: Usenet User | last post by:
..NET 1.1/2.0 I have a need to display high-resolution scrollable images in a .NET application (Windows Forms). One well known solution is to create a Panel with AutoScroll set to "true" and...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.