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. i got error on gridview in allowPaging = true - asp.net

i got error on gridview in allowPaging = true - asp.net

Scheduled Pinned Locked Moved ASP.NET
databasecsharpcssasp-netdata-structures
8 Posts 5 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.
  • G Offline
    G Offline
    Gali1978
    wrote on last edited by
    #1

    hi i have gridview in my asp.net webform. i bind my database to gridview like this: SQL = "SELECT id,Fname,Lname FROM MEN"; dsView = new DataSet(); adp = new SqlDataAdapter(SQL, Conn); adp.Fill(dsView, "MEN"); adp.Dispose(); GridView1.DataSource = dsView.Tables[0].DefaultView; GridView1.DataBind(); and this i put in the gridview: `allowPaging = true` its show the data in the grid, but if i press to page 2..3.. and i got this error: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. thanks in advance

    R T 2 Replies Last reply
    0
    • G Gali1978

      hi i have gridview in my asp.net webform. i bind my database to gridview like this: SQL = "SELECT id,Fname,Lname FROM MEN"; dsView = new DataSet(); adp = new SqlDataAdapter(SQL, Conn); adp.Fill(dsView, "MEN"); adp.Dispose(); GridView1.DataSource = dsView.Tables[0].DefaultView; GridView1.DataBind(); and this i put in the gridview: `allowPaging = true` its show the data in the grid, but if i press to page 2..3.. and i got this error: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. thanks in advance

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      It's telling you exactly what the probelm is: you have not created the PageIndexChanging event and handled it which is what you need to do unless you use one of the built in data sources that will give you paging and sorting for free. In design view, click on the grid, and view the event properties. Double-Click on the appropriate row and the method will be created for you. Now handle the event.

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      1 Reply Last reply
      0
      • G Gali1978

        hi i have gridview in my asp.net webform. i bind my database to gridview like this: SQL = "SELECT id,Fname,Lname FROM MEN"; dsView = new DataSet(); adp = new SqlDataAdapter(SQL, Conn); adp.Fill(dsView, "MEN"); adp.Dispose(); GridView1.DataSource = dsView.Tables[0].DefaultView; GridView1.DataBind(); and this i put in the gridview: `allowPaging = true` its show the data in the grid, but if i press to page 2..3.. and i got this error: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. thanks in advance

        T Offline
        T Offline
        TweakBird
        wrote on last edited by
        #3

        Gali1978 wrote:

        The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

        Write a method for binding of Gridview

        Private void BindGridView()
        {
        SQL = "SELECT id,Fname,Lname FROM MEN";
        dsView = new DataSet();
        adp = new SqlDataAdapter(SQL, Conn);
        adp.Fill(dsView, "MEN");
        adp.Dispose();
        GridView1.DataSource = dsView.Tables[0].DefaultView;
        GridView1.DataBind();
        }

        You Need Handle Gridview_pageIndexing event of GridView like this.

        GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
        GridView1.PageIndex = e.NewPageIndex;
        BindGridView();
        }

        OR After First Retrial of Data -- Put The DataSet into ViewState Or Session.(Here also Gridview1_PageIndexChanging event is Required. In this event bind the gridview with DataSet(i.e DataSet from ViewState or Session)) See This Link Gridview in ASP.NET 2.0[^] I hope you issue will clear. Try this, Post here if you face any problem.

        G 1 Reply Last reply
        0
        • T TweakBird

          Gali1978 wrote:

          The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

          Write a method for binding of Gridview

          Private void BindGridView()
          {
          SQL = "SELECT id,Fname,Lname FROM MEN";
          dsView = new DataSet();
          adp = new SqlDataAdapter(SQL, Conn);
          adp.Fill(dsView, "MEN");
          adp.Dispose();
          GridView1.DataSource = dsView.Tables[0].DefaultView;
          GridView1.DataBind();
          }

          You Need Handle Gridview_pageIndexing event of GridView like this.

          GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
          {
          GridView1.PageIndex = e.NewPageIndex;
          BindGridView();
          }

          OR After First Retrial of Data -- Put The DataSet into ViewState Or Session.(Here also Gridview1_PageIndexChanging event is Required. In this event bind the gridview with DataSet(i.e DataSet from ViewState or Session)) See This Link Gridview in ASP.NET 2.0[^] I hope you issue will clear. Try this, Post here if you face any problem.

          G Offline
          G Offline
          Gali1978
          wrote on last edited by
          #4

          thanks for the help ! but I constantly see the same records, why ?

          T D 2 Replies Last reply
          0
          • G Gali1978

            thanks for the help ! but I constantly see the same records, why ?

            T Offline
            T Offline
            TweakBird
            wrote on last edited by
            #5

            Gali1978 wrote:

            but I constantly see the same records, why ?

            May be several reasons(Not exactly) .like Table contains duplicate rows (just check it once), Check Gridview Pager Settings (Page Size, Paging Modes). If you post your modified code here, i will check it.

            1 Reply Last reply
            0
            • G Gali1978

              thanks for the help ! but I constantly see the same records, why ?

              D Offline
              D Offline
              Dhyanga
              wrote on last edited by
              #6

              try this.

               protected void GridView1\_PageIndexChanging(object sender, GridViewPageEventArgs e)
                  {
                      GridView1.PageIndex = e.NewPageIndex;
                  }
              
                  protected void GridView1\_PageIndexChanged(object sender, EventArgs e)
                  {
                      
                      GridView1.DataBind();
                  }
              

              suchita

              G 1 Reply Last reply
              0
              • D Dhyanga

                try this.

                 protected void GridView1\_PageIndexChanging(object sender, GridViewPageEventArgs e)
                    {
                        GridView1.PageIndex = e.NewPageIndex;
                    }
                
                    protected void GridView1\_PageIndexChanged(object sender, EventArgs e)
                    {
                        
                        GridView1.DataBind();
                    }
                

                suchita

                G Offline
                G Offline
                goldsoft
                wrote on last edited by
                #7

                thanks for the help, but still i see the same records

                T 1 Reply Last reply
                0
                • G goldsoft

                  thanks for the help, but still i see the same records

                  T Offline
                  T Offline
                  TweakBird
                  wrote on last edited by
                  #8

                  goldsoft wrote:

                  but still i see the same records

                  Post your code here.

                  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