Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2004, 06:57 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataGrid enable Paging

Hello I am trying to use Paging with DataGrid

Here are my settings of DataGrid:
AllowPaging = True
PageSize= 2
Enabled = True
EnableViewState = False

But when I click on page 2 I get page 1 again.
Why won't page 2 take me to page 2??


 
Old August 10th, 2004, 07:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Are you binding to the grid every time the page loads? In addition, you have to declare a PageIndexChanged event, with the following code:

ctype(sender, DataGrid).CurrentPageIndex = e.NewPageIndex
'Rebind the data grid with the new page

Brian
 
Old August 10th, 2004, 07:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Can you post your Page_Load sub?

 
Old August 12th, 2004, 06:41 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Page 1 loads fine but I get blank for page 2 even if there are other records in dataset.
I tried:

Private Sub dgBook_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles dgBook.PageIndexChanged
        dgBook.CurrentPageIndex = e.NewPageIndex
        dgBook.DataBind()


Before I omitted this when I click page 2 I got page 1 again.
Now when I click page 2 I get blank.
I know I have more records cuz when I make the PageSize bigger I see the other records than come after page 1. I also have enableViewState set to false.

When i put my mouse over page 2 link i see:
Javascript:_doPostBack('dgBook$_ctl9$_ctl1',")

What can be possibly wrong.
Thanks
 
Old August 12th, 2004, 07:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Post the code where you get the data from the data source. Without seeing that, we can't tell. That is why stu9820 asked for the Page_Load code. In addition, you need the PageIndexChanged event for it to work. Are you reloading the data source, or storing it in the session or cache? You lose the data source on page reload, because as soon as the page unload event occurs, all objects are destroyed.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom paging in Datagrid with datagrid page count madhusrp ASP.NET 1.0 and 1.1 Professional 12 June 2nd, 2008 01:15 PM
datagrid-paging kvanchi ASP.NET 1.0 and 1.1 Basics 2 December 8th, 2004 04:17 AM
Datagrid - paging mrferg Classic ASP Basics 1 December 5th, 2004 09:50 PM
Paging in datagrid Renu ASP.NET 1.0 and 1.1 Basics 2 September 9th, 2004 01:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.