473,569 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView and Paging

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 tell the Gridview that there are 750 records. Once I
get that I'm assuming I will use the PageIndex Changed to get the next page
of data.

Any points in the right direction would be appreciated.

Thanks
Wayne
Dec 13 '05 #1
4 1474
Wayne...
Here's a paste from one of my paging routines.
Dim sText As String = "EqCatECode s"

Dim sConn As String =
"SERVER=localho st;UID=****;PAS SWORD=****;DATA BASE=YourDB;"

Dim ds As DataSet = New DataSet

Dim cmd As SqlDataAdapter = New SqlDataAdapter( sText, sConn)

cmd.SelectComma nd.CommandType = CommandType.Sto redProcedure

cmd.SelectComma nd.Parameters.A dd("@cat", SqlDbType.NChar )

cmd.SelectComma nd.Parameters(" @cat").Value = Me.tbTarget.Tex t.ToString

cmd.Fill(ds, cmd.SelectComma nd.ToString)

cmd.Dispose()

Me.DataGrid1.Da taSource = ds

Me.DataGrid1.Da taBind()

DataGrid1.Curre ntPageIndex = e.NewPageIndex

DataGrid1.Page. DataBind()

hth,
bob.

"news.microsoft .com" <Me******@commu nity.nospam> wrote in message
news:eL******** ******@TK2MSFTN GP10.phx.gbl...
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 tell the Gridview that there are 750 records.
Once I get that I'm assuming I will use the PageIndex Changed to get the
next page of data.

Any points in the right direction would be appreciated.

Thanks
Wayne

Dec 13 '05 #2
If I understand the below correctly you are going to the DB doing your look
up and then assigning the Datasource to the DataGrid, then setting the page
index.

I'm not sure how this shows me how to do my own paging. I don't want to use
the built in paging directly as I have LOTS of data and already have stored
procedures already that I can tell how many rows per page, what page I'm on,
and it will return the data for the current page and the number of pages
needed.

So I need to be able to do the following:

1) Only get the data needed for the current page
2) Tell the GridView that there it will need 10 pages, this is so that it
shows all the lnks.
Please let me know if I'm missing something in your code, I'm fairly new to
the ASP.net arena.
Thanks
Wayne
"John 3:16" <bo****@tricoeq uipment.com> wrote in message
news:e6******** *****@TK2MSFTNG P10.phx.gbl...
Wayne...
Here's a paste from one of my paging routines.
Dim sText As String = "EqCatECode s"

Dim sConn As String =
"SERVER=localho st;UID=****;PAS SWORD=****;DATA BASE=YourDB;"

Dim ds As DataSet = New DataSet

Dim cmd As SqlDataAdapter = New SqlDataAdapter( sText, sConn)

cmd.SelectComma nd.CommandType = CommandType.Sto redProcedure

cmd.SelectComma nd.Parameters.A dd("@cat", SqlDbType.NChar )

cmd.SelectComma nd.Parameters(" @cat").Value = Me.tbTarget.Tex t.ToString

cmd.Fill(ds, cmd.SelectComma nd.ToString)

cmd.Dispose()

Me.DataGrid1.Da taSource = ds

Me.DataGrid1.Da taBind()

DataGrid1.Curre ntPageIndex = e.NewPageIndex

DataGrid1.Page. DataBind()

hth,
bob.

Dec 13 '05 #3
RCS
Sounds like you should try to inherit from GridView - and then override the
page stuff... ?

"news.microsoft .com" <Me******@commu nity.nospam> wrote in message
news:et******** ******@TK2MSFTN GP15.phx.gbl...
If I understand the below correctly you are going to the DB doing your
look up and then assigning the Datasource to the DataGrid, then setting
the page index.

I'm not sure how this shows me how to do my own paging. I don't want to
use the built in paging directly as I have LOTS of data and already have
stored procedures already that I can tell how many rows per page, what
page I'm on, and it will return the data for the current page and the
number of pages needed.

So I need to be able to do the following:

1) Only get the data needed for the current page
2) Tell the GridView that there it will need 10 pages, this is so that it
shows all the lnks.
Please let me know if I'm missing something in your code, I'm fairly new
to the ASP.net arena.
Thanks
Wayne
"John 3:16" <bo****@tricoeq uipment.com> wrote in message
news:e6******** *****@TK2MSFTNG P10.phx.gbl...
Wayne...
Here's a paste from one of my paging routines.
Dim sText As String = "EqCatECode s"

Dim sConn As String =
"SERVER=localho st;UID=****;PAS SWORD=****;DATA BASE=YourDB;"

Dim ds As DataSet = New DataSet

Dim cmd As SqlDataAdapter = New SqlDataAdapter( sText, sConn)

cmd.SelectComma nd.CommandType = CommandType.Sto redProcedure

cmd.SelectComma nd.Parameters.A dd("@cat", SqlDbType.NChar )

cmd.SelectComma nd.Parameters(" @cat").Value = Me.tbTarget.Tex t.ToString

cmd.Fill(ds, cmd.SelectComma nd.ToString)

cmd.Dispose()

Me.DataGrid1.Da taSource = ds

Me.DataGrid1.Da taBind()

DataGrid1.Curre ntPageIndex = e.NewPageIndex

DataGrid1.Page. DataBind()

hth,
bob.


Dec 13 '05 #4
Well I got it working, didn't override the Grid though.

I dynamicly create page links above the grid and when the user clicks on the
links I go get the new page. I wasn't worried about having to do the post
back each time as the only thing on the page is the grid.

Thanks
Wayne

"RCS" <rs****@gmail.c om> wrote in message
news:0h******** *********@newss vr19.news.prodi gy.com...
Sounds like you should try to inherit from GridView - and then override
the page stuff... ?

"news.microsoft .com" <Me******@commu nity.nospam> wrote in message
news:et******** ******@TK2MSFTN GP15.phx.gbl...
If I understand the below correctly you are going to the DB doing your
look up and then assigning the Datasource to the DataGrid, then setting
the page index.

I'm not sure how this shows me how to do my own paging. I don't want to
use the built in paging directly as I have LOTS of data and already have
stored procedures already that I can tell how many rows per page, what
page I'm on, and it will return the data for the current page and the
number of pages needed.

So I need to be able to do the following:

1) Only get the data needed for the current page
2) Tell the GridView that there it will need 10 pages, this is so that it
shows all the lnks.
Please let me know if I'm missing something in your code, I'm fairly new
to the ASP.net arena.
Thanks
Wayne
"John 3:16" <bo****@tricoeq uipment.com> wrote in message
news:e6******** *****@TK2MSFTNG P10.phx.gbl...
Wayne...
Here's a paste from one of my paging routines.
Dim sText As String = "EqCatECode s"

Dim sConn As String =
"SERVER=localho st;UID=****;PAS SWORD=****;DATA BASE=YourDB;"

Dim ds As DataSet = New DataSet

Dim cmd As SqlDataAdapter = New SqlDataAdapter( sText, sConn)

cmd.SelectComma nd.CommandType = CommandType.Sto redProcedure

cmd.SelectComma nd.Parameters.A dd("@cat", SqlDbType.NChar )

cmd.SelectComma nd.Parameters(" @cat").Value = Me.tbTarget.Tex t.ToString

cmd.Fill(ds, cmd.SelectComma nd.ToString)

cmd.Dispose()

Me.DataGrid1.Da taSource = ds

Me.DataGrid1.Da taBind()

DataGrid1.Curre ntPageIndex = e.NewPageIndex

DataGrid1.Page. DataBind()

hth,
bob.



Dec 15 '05 #5

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

Similar topics

0
2719
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update not the whole page, but a portion of the page. Strangely enough the URL below ...
2
16327
by: | last post by:
Hello, I have a GridView in my ASP.NET 2.0 application that performs the paging feature perfect when I have it bound to a data source. But now I have it bound to a dataset and the paging feature will not work. When I try to use paging I get this error: The GridView 'gvResults' fired event PageIndexChanging which wasn't handled.
1
2938
by: davidjgonzalez | last post by:
I have a GridView that has paging enabled. Each item (as defined in an ItemTemplate) includes several controls which have operations i would like to Atlas-enable. Everything is working well except when I page the GridView (the paging controllers are in the gridview's footer). The webpage doesnt scroll back to the top of the page, so when...
8
18072
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to display data in a "GridView" which is tied to an "ObjectDataSource". In turn, this ObjectDatasource gets it's data from a strongly-typed business...
2
13168
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few fields to be included in the table, which is to be bound to the gridview. The web form looks like so (Don't worry about the stupidity of this web...
5
2979
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item list that corresponds with the number of pages, but I am unable to wire up the Selected Index Changed event. Auto PostBack is set to true and the...
0
1995
by: Don Miller | last post by:
Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging without postbacks (or at least not documented how to fix it). Once the GridView is displayed, clicking on any of the paging tools causes the GridView to completely disappear! This happens when either DataSets or DataTables are used (it doesn't work at all for...
3
3733
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still coming to the client, right? I mean, the paging feature isn't somehow making calls to the database for 25 records at a time or anything like that...
4
2716
by: Don Miller | last post by:
This is a repost of a reproducible problem/bug with GridView with dynamic SQL and binding. Is there a better ASP.NET newsgroup I should post to where MS techs or MVPs take an interest in such problems? Thanks. Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging without postbacks (or at least not documented how...
4
8816
by: Peter | last post by:
I want to call a JavaScript on PageIndexChanged event, how do I do that? Thank You Peter
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
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...
0
7930
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. ...
0
8138
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...
1
7681
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...
0
7983
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...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.