GridView and Paging

N

news.microsoft.com

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
 
J

John 3:16

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.
 
N

news.microsoft.com

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
 
R

RCS

Sounds like you should try to inherit from GridView - and then override the
page stuff... ?
 
N

news.microsoft.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top