Avatar of jjc9809
jjc9809

asked on 

GridView error about Paging

Hi Everyone,

I have tried to add paging to the GridView Property by making "Allow Paging" as True.  When I run my Gridview, I get the error message, "The Data source does not support server-side data paging."

Please find my error message below.  I have also included my HTML Source Code for the Gridview.
HTML-Source-Code-for-Gridview.pdf
Error-Gridview-AllowPaging.pdf
Visual Basic.NETASP.NET

Avatar of undefined
Last Comment
jjc9809
Avatar of Mrunal
Mrunal
Flag of India image

"You can't use an IQueryable object to data bind to a GridView and still use Paging and Sorting. You must return a List to the GridView using the ToList() method."

DataReader is forward only. You can not traverse back and forth on it.
Either turn off your paging in GridView or use Datatable.
Reference:
http://forums.asp.net/p/1003175/1325804.aspx

Another approach:

http://borrell.parivedasolutions.com/2008/01/objectdatasource-linq-paging-sorting.html
Avatar of jjc9809
jjc9809

ASKER

mroonal,

I used a Datatable as suggested, and the paging stil does not work.  I am getting an error.

Please see error attached.
Server-Error-i1.doc
Avatar of Alpesh Patel
Alpesh Patel
Flag of India image

Create PageIndexChanging  event and bind grid again in event.

Like this
string CurrentPage = e.CommandArgument.ToString();
            grdAbstract.AllowPaging = true;
            grdAbstract.PageIndex = System.Convert.ToInt32(CurrentPage) - 1;
Avatar of jjc9809
jjc9809

ASKER

Patel,

I have created a Page Index Changing Event on the gridview properties.  Now do I store your code aboe inside this event along with my code for the gridview.  I am not using the wizard and are writing my code using VB.Net insead of C# code.  Are you using C# sharp code above.

VB.Net Code for this is:

Dim CurrentPage As String = e.CommandArgument.ToString()
grdAbstract.AllowPaging = True
grdAbstract.PageIndex = System.Convert.ToInt32(CurrentPage) - 1


Do I use my gridview ID for grdAbstract name you have indicated above?
My Gridview ID is called:  GVContactF

My VB Code I have written is this:

Dim myConnection = New SqlConnection(clsDAL.EnforcementIntelligenceConnection())

Dim SQL As String
        Dim cmdO As SqlCommand
        SQL = "Select * FROM Contact_tbl WHERE  FK_DriverLicenseID_vch Like '" & strLicense1.Text & "%'"

        cmdO = New SqlCommand(SQL, myConnection)


        Dim DA As New SqlDataAdapter(cmdO)
        Dim DS As New DataSet()
        DA.Fill(DS)


        GVContactF.DataSource = DS
        GVContactF.DataBind()


        Do I store my VB code in the PageIndexChangingEvent too?

  jjc9809
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of jjc9809
jjc9809

ASKER

Thanks Code Cruiser,
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo