Link to home
Start Free TrialLog in
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
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
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

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

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jjc9809

ASKER

Thanks Code Cruiser,