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. GridView Paging

GridView Paging

Scheduled Pinned Locked Moved ASP.NET
5 Posts 4 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.
  • A Offline
    A Offline
    AS 13
    wrote on last edited by
    #1

    Hello Everybody I have a gridview in my application which values are comes from a DataTable generated in codebehind(means gridview is bind to a DataTable).I want to impliment paging in the gridview. I do it as the code below but it won't work.. protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.Visible = true; GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); } Thanks in advance, Happy Coding

    A key to every Solution

    N V A 3 Replies Last reply
    0
    • A AS 13

      Hello Everybody I have a gridview in my application which values are comes from a DataTable generated in codebehind(means gridview is bind to a DataTable).I want to impliment paging in the gridview. I do it as the code below but it won't work.. protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.Visible = true; GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); } Thanks in advance, Happy Coding

      A key to every Solution

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      You are not setting the data source again. You need to set the data source again in the page index changed event, before you do DataBind().

      protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
      GridView1.Visible = true;
      GridView1.PageIndex = e.NewPageIndex;
      GridView1.DataSource = YourDataTable;
      GridView1.DataBind();
      }

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

      A 1 Reply Last reply
      0
      • A AS 13

        Hello Everybody I have a gridview in my application which values are comes from a DataTable generated in codebehind(means gridview is bind to a DataTable).I want to impliment paging in the gridview. I do it as the code below but it won't work.. protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.Visible = true; GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); } Thanks in advance, Happy Coding

        A key to every Solution

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        AS@13 wrote:

        I do it as the code below but it won't work..

        Very clear... :laugh:

        AS@13 wrote:

        GridView1.Visible = true; GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind();

        When the paging is clicked, the page will postback, where your DataTable will be clear. So you have to generate the DataTable again and assign it to the GridView. Call the DataBind now.

        [Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot

        1 Reply Last reply
        0
        • A AS 13

          Hello Everybody I have a gridview in my application which values are comes from a DataTable generated in codebehind(means gridview is bind to a DataTable).I want to impliment paging in the gridview. I do it as the code below but it won't work.. protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.Visible = true; GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); } Thanks in advance, Happy Coding

          A key to every Solution

          A Offline
          A Offline
          Anuradha612
          wrote on last edited by
          #4

          Hi, protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; Gridview1.DataSource = tblData; //this should be your data table GridView1.DataBind(); } The logic written above will work if and only if you declare your data table as shared, (i.e) shared tblData as DataTable Check out this

          1 Reply Last reply
          0
          • N N a v a n e e t h

            You are not setting the data source again. You need to set the data source again in the page index changed event, before you do DataBind().

            protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
            {
            GridView1.Visible = true;
            GridView1.PageIndex = e.NewPageIndex;
            GridView1.DataSource = YourDataTable;
            GridView1.DataBind();
            }

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

            A Offline
            A Offline
            AS 13
            wrote on last edited by
            #5

            Hi, Thanks yaar ... As it is not the exact solution for my problem but it helps me a lot to solve my problem.. thanks again.. Happy Coding

            A key to every Solution

            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