473,387 Members | 1,574 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,387 software developers and data experts.

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 1461
Wayne...
Here's a paste from one of my paging routines.
Dim sText As String = "EqCatECodes"

Dim sConn As String =
"SERVER=localhost;UID=****;PASSWORD=****;DATABASE= YourDB;"

Dim ds As DataSet = New DataSet

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

cmd.SelectCommand.CommandType = CommandType.StoredProcedure

cmd.SelectCommand.Parameters.Add("@cat", SqlDbType.NChar)

cmd.SelectCommand.Parameters("@cat").Value = Me.tbTarget.Text.ToString

cmd.Fill(ds, cmd.SelectCommand.ToString)

cmd.Dispose()

Me.DataGrid1.DataSource = ds

Me.DataGrid1.DataBind()

DataGrid1.CurrentPageIndex = e.NewPageIndex

DataGrid1.Page.DataBind()

hth,
bob.

"news.microsoft.com" <Me******@community.nospam> wrote in message
news:eL**************@TK2MSFTNGP10.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****@tricoequipment.com> wrote in message
news:e6*************@TK2MSFTNGP10.phx.gbl...
Wayne...
Here's a paste from one of my paging routines.
Dim sText As String = "EqCatECodes"

Dim sConn As String =
"SERVER=localhost;UID=****;PASSWORD=****;DATABASE= YourDB;"

Dim ds As DataSet = New DataSet

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

cmd.SelectCommand.CommandType = CommandType.StoredProcedure

cmd.SelectCommand.Parameters.Add("@cat", SqlDbType.NChar)

cmd.SelectCommand.Parameters("@cat").Value = Me.tbTarget.Text.ToString

cmd.Fill(ds, cmd.SelectCommand.ToString)

cmd.Dispose()

Me.DataGrid1.DataSource = ds

Me.DataGrid1.DataBind()

DataGrid1.CurrentPageIndex = 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******@community.nospam> wrote in message
news:et**************@TK2MSFTNGP15.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****@tricoequipment.com> wrote in message
news:e6*************@TK2MSFTNGP10.phx.gbl...
Wayne...
Here's a paste from one of my paging routines.
Dim sText As String = "EqCatECodes"

Dim sConn As String =
"SERVER=localhost;UID=****;PASSWORD=****;DATABASE= YourDB;"

Dim ds As DataSet = New DataSet

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

cmd.SelectCommand.CommandType = CommandType.StoredProcedure

cmd.SelectCommand.Parameters.Add("@cat", SqlDbType.NChar)

cmd.SelectCommand.Parameters("@cat").Value = Me.tbTarget.Text.ToString

cmd.Fill(ds, cmd.SelectCommand.ToString)

cmd.Dispose()

Me.DataGrid1.DataSource = ds

Me.DataGrid1.DataBind()

DataGrid1.CurrentPageIndex = 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.com> wrote in message
news:0h*****************@newssvr19.news.prodigy.co m...
Sounds like you should try to inherit from GridView - and then override
the page stuff... ?

"news.microsoft.com" <Me******@community.nospam> wrote in message
news:et**************@TK2MSFTNGP15.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****@tricoequipment.com> wrote in message
news:e6*************@TK2MSFTNGP10.phx.gbl...
Wayne...
Here's a paste from one of my paging routines.
Dim sText As String = "EqCatECodes"

Dim sConn As String =
"SERVER=localhost;UID=****;PASSWORD=****;DATABASE= YourDB;"

Dim ds As DataSet = New DataSet

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

cmd.SelectCommand.CommandType = CommandType.StoredProcedure

cmd.SelectCommand.Parameters.Add("@cat", SqlDbType.NChar)

cmd.SelectCommand.Parameters("@cat").Value = Me.tbTarget.Text.ToString

cmd.Fill(ds, cmd.SelectCommand.ToString)

cmd.Dispose()

Me.DataGrid1.DataSource = ds

Me.DataGrid1.DataBind()

DataGrid1.CurrentPageIndex = 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
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...
2
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...
1
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...
8
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...
2
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...
5
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...
0
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...
3
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...
4
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...
4
by: Peter | last post by:
I want to call a JavaScript on PageIndexChanged event, how do I do that? Thank You Peter
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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?
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,...

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.