Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. LINQ and GridView Paging...

LINQ and GridView Paging...

Scheduled Pinned Locked Moved LINQ
helpcsharpdatabaselinqsysadmin
2 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Illegal Operation
    wrote on last edited by
    #1

    I have a problem. I have created a LINQ query and bind it to a gridview and it works but if I enable Allowpaging = true i get this error: The data source does not support server-side data paging. Can anyone tell me how I can work around this? I have set the gridview to Allowpaging=true and EnableSortingAndPagingCallbacks=true but it still won't work! My Code:

    protected void GetCasesByID(DataSet ds)
    {
        if (IsLoggedIn == false)
        {
            gv\_CaseDetails.DataSource = from a in ds.Tables\[0\].AsEnumerable()
                                        from b in ds.Tables\[2\].AsEnumerable()
                                        where a.Field<string>("CaseId") == txtCaseID.Text && a.Field<string>("Password") == txtPassword.Text
                                        select new
                                        {
                                            CaseManager = a.Field<string>("CaseManager"),
    
                                            NoteCreated = b.Field<string>("NoteCreated"),
                                            NoteContent = b.Field<string>("NoteContent"),
                                        };
    
            gv\_CaseDetails.DataBind();
    
            IsLoggedIn = true;
        }
    }
    

    Illegal Operation

    H 1 Reply Last reply
    0
    • I Illegal Operation

      I have a problem. I have created a LINQ query and bind it to a gridview and it works but if I enable Allowpaging = true i get this error: The data source does not support server-side data paging. Can anyone tell me how I can work around this? I have set the gridview to Allowpaging=true and EnableSortingAndPagingCallbacks=true but it still won't work! My Code:

      protected void GetCasesByID(DataSet ds)
      {
          if (IsLoggedIn == false)
          {
              gv\_CaseDetails.DataSource = from a in ds.Tables\[0\].AsEnumerable()
                                          from b in ds.Tables\[2\].AsEnumerable()
                                          where a.Field<string>("CaseId") == txtCaseID.Text && a.Field<string>("Password") == txtPassword.Text
                                          select new
                                          {
                                              CaseManager = a.Field<string>("CaseManager"),
      
                                              NoteCreated = b.Field<string>("NoteCreated"),
                                              NoteContent = b.Field<string>("NoteContent"),
                                          };
      
              gv\_CaseDetails.DataBind();
      
              IsLoggedIn = true;
          }
      }
      

      Illegal Operation

      H Offline
      H Offline
      Howard Richards
      wrote on last edited by
      #2

      I think the error is self-explanatory. The gridview does not have a way to page because the datasource isn't pageable.. If paging is required, databind the gridview to an ObjectDataSource. Then write a paged select and pagecount function for your data. You'll need to define a class or struct to hold the resultset as well.. e.g. [

      DataObject(true)]
      public class MyDataSource
      {

      [DataObjectMethod(Select)]
      public static *somereturntype* SelectPaged( *params*, int startRowIndex, int maximumRows )
      {
      // do paged select
      }

      public static int SelectRowCount( *params*, int startRowIndex, int maximumRows )
      {
      // compute total rowcount
      }
      }

      'Howard

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups