locked
I have a scenario with GridView - Need inputs RRS feed

  • Question

  • User661550187 posted

    Hi,

      I have GridView that pulls a datasource that returns many a thousands of records. I am thinking of a scenario where I just pull the frist 1000 records and display them. And if user is interested to view the rest of the records then go to the database and display the other 1000 records and so on.

    The things I need to figure out are below:

    1).Is there way I can put a link that reads "Click here for newxt 1000 records" right next to the paging (pager at the bottom of the grid). If so then how do I go about it.

    2).How do I get only the first set amount of records (say first 500 or 1000 ...) out of thousands of recrods from the datasource. Is there an in ADO.NET to use or can any body proivde some inputs?

     

    We are using .NET 3.5 and SQLserver 2008.

     

    Thanks in advance,

     

    L

     

    Tuesday, May 17, 2011 7:40 AM

Answers

  • User-851968219 posted

    This link can help you get started

    http://www.codeproject.com/KB/webforms/GridViewCustomPaging.aspx

    The idea is that when you hit next, you keep track of the next page number either in a viewstate or using the pager control. Based on that page number and number of records you are trying to show, you get the rownumber from where you want to get your result, for example, if page number is 2 and you are displaying 10 records per page, page 2's result should start from row ((Pagenumber-1) * numberofrecords). Based on the starting index of the row that you want to return, just return the number of rows that you need from the query.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 17, 2011 12:55 PM

All replies

  • User860067021 posted

    You do you bind your gridview?

    Can you include a TOP X on SQL Statement?

    Tuesday, May 17, 2011 7:51 AM
  • User1048482649 posted

    You can put a LinkButton control in particular columns FooterTemplate.

    1).Is there way I can put a link that reads "Click here for newxt 1000 records" right next to the paging (pager at the bottom of the grid). If so then how do I go about it.

    Yes. Use TOP clause in your query. For example - "SELECT TOP 10 * FROM Customer" would fetch the top 10 records from the Customer table.

    2).How do I get only the first set amount of records (say first 500 or 1000 ...) out of thousands of recrods from the datasource. Is there an in ADO.NET to use or can any body proivde some inputs?

     


     HTH
    Ritesh

    Tuesday, May 17, 2011 7:52 AM
  • User-1569880281 posted

    Hi,

    Exactly your problem/scenario is described very well in this following link please read the tutorial, it will definately help you.

    http://www.asp.net/data-access/tutorials/efficiently-paging-through-large-amounts-of-data-cs

     

    Tuesday, May 17, 2011 7:55 AM
  • User-851968219 posted

    This link can help you get started

    http://www.codeproject.com/KB/webforms/GridViewCustomPaging.aspx

    The idea is that when you hit next, you keep track of the next page number either in a viewstate or using the pager control. Based on that page number and number of records you are trying to show, you get the rownumber from where you want to get your result, for example, if page number is 2 and you are displaying 10 records per page, page 2's result should start from row ((Pagenumber-1) * numberofrecords). Based on the starting index of the row that you want to return, just return the number of rows that you need from the query.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 17, 2011 12:55 PM
  • User3866881 posted

    Hi:)

    This should be down with Effective Paging Stored procdure as well as to handle the GridView's PageIndexChanging and PageIndexChanged——

    http://www.codeproject.com/KB/aspnet/EffectivePaging.aspx

    Wednesday, May 18, 2011 10:43 PM