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. Change Datagrid default display page?

Change Datagrid default display page?

Scheduled Pinned Locked Moved ASP.NET
question
8 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.
  • N Offline
    N Offline
    NetRams
    wrote on last edited by
    #1

    Hi, I am having datagrid with pagesize 5 and dataset which returns 20 records and binds with datagrid. What I need is to display the datagrid by default from 2 page - that is from 6th record of my dataset result. How could i do this? Any luck. Rams.

    Be simple and Be sample.

    C G 2 Replies Last reply
    0
    • N NetRams

      Hi, I am having datagrid with pagesize 5 and dataset which returns 20 records and binds with datagrid. What I need is to display the datagrid by default from 2 page - that is from 6th record of my dataset result. How could i do this? Any luck. Rams.

      Be simple and Be sample.

      C Offline
      C Offline
      Chetan Ranpariya
      wrote on last edited by
      #2

      Hi, dg.CurrentPageIndex = 2; dg.DataBind();

      Thanks and Regards, Chetan Ranpariya

      N 1 Reply Last reply
      0
      • C Chetan Ranpariya

        Hi, dg.CurrentPageIndex = 2; dg.DataBind();

        Thanks and Regards, Chetan Ranpariya

        N Offline
        N Offline
        NetRams
        wrote on last edited by
        #3

        Thanks, When i change currentpageindex, then I can't go to previous page. How to get rid of it.

        Be simple and Be sample.

        C M 3 Replies Last reply
        0
        • N NetRams

          Thanks, When i change currentpageindex, then I can't go to previous page. How to get rid of it.

          Be simple and Be sample.

          M Offline
          M Offline
          Manas Bhardwaj
          wrote on last edited by
          #4

          Make sure you handle the event PageIndexChanged for datagrid. Set DataGrid.CurrentPageIndex = e.NewPageIndex; Hope this works :)

          1 Reply Last reply
          0
          • N NetRams

            Thanks, When i change currentpageindex, then I can't go to previous page. How to get rid of it.

            Be simple and Be sample.

            C Offline
            C Offline
            Chetan Ranpariya
            wrote on last edited by
            #5

            Hi, Can you post your code of GridBinding and PageIndexChangedEvent ?

            Thanks and Regards, Chetan Ranpariya

            M 1 Reply Last reply
            0
            • C Chetan Ranpariya

              Hi, Can you post your code of GridBinding and PageIndexChangedEvent ?

              Thanks and Regards, Chetan Ranpariya

              M Offline
              M Offline
              Manas Bhardwaj
              wrote on last edited by
              #6

              In the PageIndexChanged Event Write DataGrid.CurrentPageIndex = e.NewPageIndex; //Bind DataGrid with DataSource //Use the same code which you used to bind the data initially...

              1 Reply Last reply
              0
              • N NetRams

                Hi, I am having datagrid with pagesize 5 and dataset which returns 20 records and binds with datagrid. What I need is to display the datagrid by default from 2 page - that is from 6th record of my dataset result. How could i do this? Any luck. Rams.

                Be simple and Be sample.

                G Offline
                G Offline
                ganti r
                wrote on last edited by
                #7

                Hi, I haven't tried this, but I feel setting the "datagrid.pageindex" value should help you.

                rAm i Think, i Wait, i Fast -- Siddartha

                1 Reply Last reply
                0
                • N NetRams

                  Thanks, When i change currentpageindex, then I can't go to previous page. How to get rid of it.

                  Be simple and Be sample.

                  C Offline
                  C Offline
                  Chetan Ranpariya
                  wrote on last edited by
                  #8

                  Hi, I have done this thing by following way and it works fine for me. I Page_Load i have writen the following to bind my datagrid for the fist time. if(!isPostBack) { dgSearchResult.CurrentPageIndex = 1; // This will show 2nd page initially as u wanted to. dgSearchResult.DataSource = dst.Tables["Products"]; dgSearchResult.DataBind(); } and in PageIndexChanged event of datagrid I have written the following code. dgSearchResult.CurrentPageIndex = e.NewPageIndex; dgSearchResult.DataSource = dst.Tables["Products"]; dgSearchResult.DataBind(); I hope this will help you.

                  Thanks and Regards, Chetan Ranpariya

                  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