gridview page index change with same page link


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: gridview page index change with same page link

  1. #1
    Join Date
    Jan 2009
    Posts
    2

    gridview page index change with same page link

    hi,

    i have a web page with 2 gridviews stacked vertically, something like below.

    |--------------- Gridview 1----------------------jump to GV 2-------------------|

    |

    |

    |----------------------------------------------------------------------|

    Back to top

    |--------------------Gridview 2 ---------------------------------- |

    |

    |

    |---------------------------------------------------------------------|

    i have setup a same-page link at the top of the page to jump to the 2nd gridview, which works fine. my problem is:

    when there are multiple pages of data returned in gridview2, and the user clicks '2' or '3' to go to the next page of gridview2 results, the page is reloaded and displays from the top.

    question: is there a way to incorporate the same page link on page index change of the gridview? when the user changes pages in gridview2, have the page reload and jump to the named anchor on the page mypage.aspx#gridview2

    thanks

  2. #2
    Join Date
    Jan 2009
    Posts
    2

    Smile alternate solution

    well, after more digging, i figured out an alternate way to place the user at the second gridview. in case it will help anyone else:

    added a javascript function to the page source that uses scrollintoview

    -----------------------------------------------------------------------

    <script type="text/javascript">
    function scrollToStu()
    {
    var el = document.getElementById("studentgrid");
    el.scrollIntoView(true);
    }
    </script>

    ---------------------------------------------------------------------------------------

    next, in the code behind file, i added a registerStartupScript command in the PageIndexChanging function of the 2nd gridview.



    protected void stugridView_PageIndexChanging(object sender, GridViewPageEventArgs e)

    {

    RegisterStartupScript("scrolling", "<script>scrollToStu()</script>");

    }

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Thanks for posting your solution and welcome to DevX

    Hopefully your post will help someone else with the same or similiar problem.
    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. Change page title on AJAX site...JS?
    By raindance in forum AJAX
    Replies: 11
    Last Post: 12-17-2008, 07:27 PM
  2. Tabbed page controlling dynamic GridView?
    By diverguy in forum ASP.NET
    Replies: 4
    Last Post: 04-11-2008, 05:54 PM
  3. trying to make a link on an xsl page
    By Usha Dewasthali in forum XML
    Replies: 3
    Last Post: 06-14-2001, 11:39 AM
  4. how to open print dialog box from html page or link or button
    By santosh Kumar Racharla in forum Web
    Replies: 1
    Last Post: 02-14-2001, 06:24 PM
  5. Replies: 0
    Last Post: 08-31-2000, 06:48 PM

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