Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 July 25th, 2006, 04:07 PM
Authorized User
 
Join Date: Jun 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default datagrid pageindex

I have datagrid (total records 7) and pagesize is 6 and pager style is numeric and two columns (name column and checkbox column and all are checked)

by default, currentpageindex is 0 and first 6 records appearing and clicked on 2nd page and it shows 7th record. when uncheck 7th checkbox(2nd page) and click on save button, saving user selection to Database and populating grid again.

now total record count is 6 and current pageindex should be 0. but it is not changing and pageindex remains 1 and I gotta error for this case.

"Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount."

Can anybody help?

Thanks



__________________
Rams
 
Old July 25th, 2006, 10:49 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Have you physically tried setting the PageIndex to 0? See if that clears up your error.

"The one language all programmers understand is profanity."
 
Old July 26th, 2006, 08:34 AM
Authorized User
 
Join Date: Jun 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

finally i ended up with following calculation/solution and is working good.


        If dtSelectedInstitutions.Rows.Count > 6 Then
            If dtSelectedInstitutions.Rows.Count / 6 > dgSI.CurrentPageIndex Then
                sPageIndex = dgSI.CurrentPageIndex - 1
                If sPageIndex = -1 Then dgSI.CurrentPageIndex = 0
            Else
                dgSI.CurrentPageIndex = dgSI.CurrentPageIndex - 1
            End If
        Else
            dgSI.CurrentPageIndex = 0
        End If



 
Old July 26th, 2006, 02:26 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

I had a similar problem with paging in a datagrid. My was due to changes in search criteria. It seems like dparsons idea should work. I tried working it out with IF statements and it didn't work in the long run. To fix it I had to clear the grid and reload it which also set the index back to zero.

Good luck.

Richard






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
detailsview.pageindex = gridview.selectedindex yukijocelyn ASP.NET 2.0 Basics 2 September 11th, 2007 08:36 PM
User COntrol Datagrid inside datagrid rodmcleay ASP.NET 1.0 and 1.1 Professional 3 April 14th, 2007 10:11 AM
Creating DataGrid In Repeater/DataGrid liduwan ASP.NET 1.0 and 1.1 Professional 9 March 6th, 2007 03:31 PM
DataGrid akumarp2p C# 1 December 20th, 2006 08:42 AM





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