473,799 Members | 3,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2013
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.Page Count > 1)
grdAlan.PagerSt yle.Visible = true;
else
grdAlan.PagerSt yle.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.Page Count > 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*********@no spam.thanx> wrote in message
news:Y5******** ******@nospamth ankyou.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.Page Count > 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_Item Created(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
YourDGHere.Item Created
If e.Item.ItemType = ListItemType.Pa ger Then
If sender.PageCoun t = 1 Then
sender.PagerSty le.Visible = False
Else
Dim pageOf As String
Dim tablecellp As TableCell = CType(e.Item.Co ntrols(0),
TableCell)
If sender.PageCoun t > 1 Then
pageOf = "Select page: "
Else
YourDGHere.Page rStyle.Visible = False
End If
tablecellp.Cont rols.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_Item Created(ByVal sender As Object, ByVal e As
System.Web.UI. WebControls.Dat aGridItemEventA rgs) Handles
YourDGHere.Ite mCreated
If e.Item.ItemType = ListItemType.Pa ger Then
If sender.PageCoun t = 1 Then
sender.PagerSty le.Visible = False
Else
Dim pageOf As String
Dim tablecellp As TableCell = CType(e.Item.Co ntrols(0),
TableCell)
If sender.PageCoun t > 1 Then
pageOf = "Select page: "
Else
YourDGHere.Page rStyle.Visible = False
End If
tablecellp.Cont rols.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
2377
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 standard paging techniques use a linkbutton, which runs a small piece of client-side javascript. To my understanding, this means that when I get "spidered" by a search engine, it won't follow the javascript links, thereby my database won't get...
4
1848
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 = //COUNT FROM STORED PROC grid.Datasource =a; grid.DataBind();
8
4150
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 repeater working, and paging/sorting works, but there is a small bug that I can't seem to figure out. If, for example, I display 5 records per page, the paging function executes fine, and only shows 5 records per page. This is no problem. When I...
2
2225
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
1833
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 paging for the MasterDataGrid which works well but when i page to the next set of rows and select a particular ROW(for example SHOW DETAILS) to populated the Child Datagrid after paging to the next page it doesn't work.. it just sends me back to the...
4
1481
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 75 records from the DB, I know there are 750 records total in the DB. How can I control the paging? I don't want to go and get all 750 records at once then allow the grid view to do the paging. Currently the biggest issue I'm facing is how to...
1
2395
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 does only with javascript. I know how to set the index of the grid etc. My Idea would be using my own links (with query-parameters attached on them, the parameter would transport the position of the targeted page in the grid) I just need basicaly a...
7
2332
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, etc.) suggest using an ObjectDataSource which has built-in paging functionality that, when used in conjunction with certain SQL 2005 functionality, only works with the records to be displayed on the page rather than the entire set. The problem with...
2
3669
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 false and also tried to set the footerstyle height to 0px, but it always seems to show. Is there any way to hide the footer?
0
9543
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.