Possible Bug in GridView Paging


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: Possible Bug in GridView Paging

  1. #1
    Join Date
    Aug 2008
    Posts
    1

    Possible Bug in GridView Paging

    In my current project, I'm doing a lot of work with GridViews. I wanted to use Previous and Next buttons for paging, but I stumbled on a what I think is a bug in ASP.NET 3.5 with Service Pack 1. If you set AllowPaging = True and you use PagerSettings Mode = Numeric, everything works fine. However, if you switch to a Mode = NextPrevious or NextPreviousFirstLast, GridViewPageEventArgs.NewPageindex will sometimes return a value of -1 when you click on the Previous link to get to the first page or the First link. Since the range of valid values is 0 to the number of pages - 1, this is an invalid value that will cause your application to crash. Also, if you click on the Next link, it will sometimes freeze on the same page and not move forward even if there are move pages to go. Has anyone else seen this behavior?

    Paul M. Frazier, Ph.D.

  2. #2
    Join Date
    Sep 2008
    Posts
    1
    Ahh... ok... so I'm not the only one seeing this problem. It's been driving me crazy for two days now. Do you think it's an SP1 thing? I haven't tried to uninstall SP1 yet, but maybe that is in order.

    I've experienced this same problem with custom pagers, but it all calls the same underlying code.

    David

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Welcome to DevX (both of you)

    I've also experienced this problem. I put my paging code in a Try/Catch and simply ignored the error....primarily because I've turned up no solutions for a fix through Goggling and this prevents the app from crashing.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Oct 2008
    Posts
    3

    Pageindex problem with Next/Prev

    I ran into this but I worked around it by trapping the PageIndexChanging event and checking the NewPageIndex property of GridViewPageEventArgs argument. If I didn't like the new value, I didn't set it into the current gridview.pageindex.

  5. #5
    Join Date
    Jan 2009
    Posts
    1
    Hi,

    I have same problem with ASP.NET 3.5 GridView. Sorting & Paging does not work. but if run the same code in FireFox or Google Chrome. it is working.

    I have installed VS .NET 2008 SP1, but before that I never observe such issues.

    also I have implemented the server side code for on change of paging index.

    web parts buttons (restore,close,minimize) also does not work. this is a similar problem across many of the server controls.

    any alternatives...Please help.

  6. #6
    Join Date
    Mar 2009
    Posts
    3
    I have joined up purely because i have found absolutely no other reference to this specific issue!

    All of a sudden gridview pagination and sorting has stopped working.

    I am using the most BASIC code in a completely new project.

    Code:
    <asp:DataGrid ID="dgTest" DataSourceID="dataSource" runat="server"  
    AllowSorting="true" AutoGenerateColumns="true">
    </asp:DataGrid>
    
    <asp:SqlDataSource   ID="dataSource" runat="server" ConnectionString="<%$ ConnectionStrings:DataBase%>"
    SelectCommand="SELECT * FROM [Property]">
    </asp:SqlDataSource>
    In the above example sorting should work on any of the columns returned by the select. However when clicking on the column a postback fires but no sorting occurs. I've been stuck on this for several days now.

    Is this a .NET 3.5 SP1 bug? I uninstalled sp1 and the issue is still present.

    Any insight would be awesome.

    Galen

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by galen View Post
    All of a sudden gridview pagination and sorting has stopped working.
    Things like this do not happen in a vacuum for no reason. What changed in your environment?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  8. #8
    Join Date
    Mar 2009
    Posts
    3
    Sorry, please don't get me wrong. I am an 8 year experienced developer and agree and understand exactly with what you have just said.

    I came upon this thread after days of googling for assistance for information relating to my issue. I have tested in two environments, both have had .net 3.5 SP1 installed.

    This thread also indicated (from previous posts) that others have had similiar issues with sorting and pagination since upgrading to sp1. Unfortunately, this thread has been the only sliver of comparable results that i have been able to find.

    Even still, my head says.. environment or configuration related. Otherwise there would be **** being raised all over the .net blogs regarding such a bug. Since there isnt, i would assume the issue is either very specific or isolated to the environment. Since the others reported something similiar, im hoping to get more info or clues that might point to what could be the problem.

    So in summary... the most basic pagination and sorting functionality of a gridview does not seem to be working for me since upgrading to .net 3.5 sp1. Across 2 environments.

    Galen

  9. #9
    Join Date
    Mar 2009
    Posts
    3
    Its with a very embarassed face that i come here to state what was causing the issue.

    If you notice from my post above, the control i used to represent the data is a 'DataGrid' as opposed to a 'GridView'. No automatic sorting or paging works in datagrids in the latter versions of .net.

    My head is sore from banging it on the desk.

  10. #10
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by galen View Post
    If you notice from my post above, the control i used to represent the data is a 'DataGrid' as opposed to a 'GridView'. No automatic sorting or paging works in datagrids in the latter versions of .net.
    Actually, I did not notice that.

    Thanks for coming back and posting the solution. You may have saved someone else from getting a sore head.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. paging in gridview in asp.net 2.0
    By anshuman in forum ASP.NET
    Replies: 3
    Last Post: 04-21-2009, 03:31 AM
  2. ASP.NET 2 Textbox value in Gridview row
    By timmym in forum ASP.NET
    Replies: 8
    Last Post: 11-23-2008, 08:31 AM
  3. Sorting in GridView with Paging
    By ash_mangu in forum ASP.NET
    Replies: 1
    Last Post: 07-31-2007, 06:36 AM
  4. Help - GridView Paging Not Working
    By calicojoe in forum ASP.NET
    Replies: 1
    Last Post: 08-08-2006, 06:02 PM
  5. Replies: 0
    Last Post: 10-11-2005, 09:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center