We help IT Professionals succeed at work.

POPULATE GRIDVIEW VIA DATAREADER - PAGING

mugsey
mugsey asked
on
945 Views
Last Modified: 2012-05-05
I know that you cannot implement paging in a gridview that is populated via a datareader but say you have 15,000 rows can you specify the grid to display 20 rows per page?  I need to loop through all the rows of the gridview which maybe 15000 or so but need to display the gridview in pages.
Comment
Watch Question

http://www.codeproject.com/useritems/DataGridPaging_DataReader.asp

This article explains how to manually implement pagination in a datagrid that is bound to a datareader
Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
>> I know that you cannot implement paging in a gridview that is populated via a datareader

You canot what ??? You talking about gridview or datagrid ?

If it is gridview from VS2005 it's an easy strep.

Author

Commented:
I am using a GRIDVIEW but using a datareader can you implement paging?
mugsey, did u check out the link i sent u?

Author

Commented:
Yes thanks but I need it for ASP.NET not windows forms.  I think I will use a dataset - have you a good example of this?  
You see, say if I have 20,000 rows, and allow the gridview to display say 20 rows per page, can I still iterate through all of the 20,000 rows?

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
Why dont you use something like this :

Private Const myConnectionString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename='|DataDirectory|\myData.MDF';Integrated Security=True;User Instance=True"

    Public Shared Function FillGridView(ByVal gv As GridView, ByVal SQL As String) As Boolean
        Dim ds As New SqlDataSource

        With ds
            ds.ConnectionString = myConnectionString
            ds.SelectCommand = SQL
        End With

        gv.DataSource = ds
        gv.DataBind()
    End Function

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.