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

How do I remove the paging links from a data grid when there's only one page?

Hello,

I have been playing with the data grid, which looks very powerful for
providing paged views of your data, but I don't like the way the footer
bits are displayed when there's only one page. You still get the links,
well text really, but they don't mean anything.

Can these be switched off? If not, can I at least add some text to the
footer? I would like to do this anyway as it's not always immediately
obvious that these are paging links.

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #1
6 2000
Pat
Alan,
It is very easy. Throw the following code into the bottom of the
function that sources, binds and displays your datagrid. Convention:
name of the datagrid will be 'grdAlan'.

if(grdAlan.PageCount > 1)
grdAlan.PagerStyle.Visible = true;
else
grdAlan.PagerStyle.Visible = false;

Nov 19 '05 #2
>Alan,
It is very easy. Throw the following code into the bottom of the
function that sources, binds and displays your datagrid. Convention:
name of the datagrid will be 'grdAlan'.
Thanks for the quick response. I tried this, but on the line...
if(grdAlan.PageCount > 1)


the compiler gave an error...

"CS1014: A get or set accessor expected"

Any idea why? I looked in the SDK, and it looks like it should work as
you typed it.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #3
>the compiler gave an error...

Ignore that, it was my stupid mistake. I put the code in a method and
forgot to add the () after the name, so the compiler thought it was a
property. Ho hum.

I would still like to know if you can add text to the footer. Just
having numbers there is a bit unfriendly. It would be nice if you could
change it to "Go to page 1 2 3..."

Any ideas? Thanks again.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #4
You have to replace the name 'grdAlan' which Pat made up to convey how to
write the code. Replace the name grdAlan with the actual name of the grid
object used in 'your' code.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Alan Silver" <al*********@nospam.thanx> wrote in message
news:Y5**************@nospamthankyou.spam...
Alan,
It is very easy. Throw the following code into the bottom of the
function that sources, binds and displays your datagrid. Convention:
name of the datagrid will be 'grdAlan'.


Thanks for the quick response. I tried this, but on the line...
if(grdAlan.PageCount > 1)


the compiler gave an error...

"CS1014: A get or set accessor expected"

Any idea why? I looked in the SDK, and it looks like it should work as you
typed it.

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #5
I did this the other day, but wanted to adjust it to show the current
page like
"Page 3 of 22" - Select page: 1 2 3 4 5 6... >" or something cleaner,
but you get the idea, with the code below you can do what ever you want
in the pager. I've even displayed the total record count in the pager
right aligned. You can add cells and merge cells and do colspans, what
ever you so choose. You could even add rows under or above your
footer.
Jeff
Private Sub YourDGHere_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
YourDGHere.ItemCreated
If e.Item.ItemType = ListItemType.Pager Then
If sender.PageCount = 1 Then
sender.PagerStyle.Visible = False
Else
Dim pageOf As String
Dim tablecellp As TableCell = CType(e.Item.Controls(0),
TableCell)
If sender.PageCount > 1 Then
pageOf = "Select page: "
Else
YourDGHere.PagerStyle.Visible = False
End If
tablecellp.Controls.AddAt(0, New
LiteralControl(pageOf))
End If
End If
End Sub

Nov 19 '05 #6
That's fantastic, thanks a lot. I was actually very surprised at the
lack of control you have over this, especially given the amount of
control you have over everything else in the datagrid.

I'll go and play with this. Thanks again
I did this the other day, but wanted to adjust it to show the current
page like
"Page 3 of 22" - Select page: 1 2 3 4 5 6... >" or something cleaner,
but you get the idea, with the code below you can do what ever you want
in the pager. I've even displayed the total record count in the pager
right aligned. You can add cells and merge cells and do colspans, what
ever you so choose. You could even add rows under or above your
footer.
Jeff
Private Sub YourDGHere_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs ) Handles
YourDGHere.ItemCreated
If e.Item.ItemType = ListItemType.Pager Then
If sender.PageCount = 1 Then
sender.PagerStyle.Visible = False
Else
Dim pageOf As String
Dim tablecellp As TableCell = CType(e.Item.Controls(0),
TableCell)
If sender.PageCount > 1 Then
pageOf = "Select page: "
Else
YourDGHere.PagerStyle.Visible = False
End If
tablecellp.Controls.AddAt(0, New
LiteralControl(pageOf))
End If
End If
End Sub


--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #7

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

Similar topics

1
by: Duncan Welch | last post by:
I am in the process of developing a site that will, on completion, be quite high profile. I have successfully used the Datagrid to display paged data from a database of around 10k records, but the...
4
by: Happy | last post by:
hi I got a datagrid with Paging enabled which is getting populated thru a stored proc. I've given the code in the event grid.CurrentPageIndex = e.NewPageIndex grid.VirtualItemCount =...
8
by: Matthew Curiale | last post by:
I am creating an app that lists clients of a company for management of different attributes for that company. The first page is a listing of the companies currently in the database. I have my...
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
3
by: Pat | last post by:
I have a 2 nested Datagrid. When i select a row in the Master Datagrid i populate the Child databrid using myDataGrid.SelectedIndex value as the filter and setting the DataKeyField. I enabled...
4
by: news.microsoft.com | last post by:
I've looked in the help and at each of the properties for the grid view, but can't seem to find what I need. I have allowpaging set to true for my gridview and when the page loads I go and fetch...
1
by: the friendly display name | last post by:
Simple question: How to make datagrid paging work without javascript? I have a simple datagrid, which gets populated by a dataview, it works perfectly, paging works too, but, as I said, it...
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,...
2
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hello, I have an asp.net 2.0 gridview with the paging enabled. I don't want to display the footer, but it always displays with the page numbers displayed. I have set the grid's showfooter to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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.