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. Web Development
  3. ASP.NET
  4. paging without sqlDataSource control..

paging without sqlDataSource control..

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelptutorial
2 Posts 2 Posters 0 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.
  • D Offline
    D Offline
    dittu7
    wrote on last edited by
    #1

    hi every one, can anyone tell me how to do paging for gridView in asp.net without using the sqlDataSource control, on clicking next it has to show the next page, on clicking prev it has to show the previous page in the gridView control. just like the operation we get in sqlDataSource control. i'm fresher pls explain in detail. any links also will help me great.. thanks in advance dittu :)

    L 1 Reply Last reply
    0
    • D dittu7

      hi every one, can anyone tell me how to do paging for gridView in asp.net without using the sqlDataSource control, on clicking next it has to show the next page, on clicking prev it has to show the previous page in the gridView control. just like the operation we get in sqlDataSource control. i'm fresher pls explain in detail. any links also will help me great.. thanks in advance dittu :)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try following code.

      //For paging a Gridview manually we have to handle the Gridview’s PageIndexChanged Event.
      //In the event we need to change the PageIndex of Gridview to the page that user has clicked and again bind the Gridview.

      protected void gvPaging_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
      gvPaging.PageIndex = e.NewPageIndex;
      gvPaging.DataBind();
      }

      //This is all you need to do to make manual paging in the Gridview.
      //For manually sorting in Gridview we need to handle the Sorting event of Gridview. Here is the code to do it.

      protected void gvSorting_Sorting(object sender, GridViewSortEventArgs e)
      {
      DataTable dtSortTable = gvSorting.DataSource as DataTable;

      if (dtSortTable != null)
      {
      DataView dvSortedView = new DataView(dtSortTable);
      dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString(e.SortDirection);

        gvSorting.DataSource = dvSortedView;
        gvSorting.DataBind();
      

      }
      }

      private string getSortDirectionString(SortDirection sortDireciton)
      {
      string newSortDirection = String.Empty;
      if(sortDirection== SortDirection.Ascending)
      {
      newSortDirection = "ASC";
      }
      else
      {
      newSortDirection = "DESC";
      }
      return newSortDirection
      }

      HTH

      Jinal Desai - LIVE Experience is mother of sage....

      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