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 - PageIndexChanging not handled

GridView - PageIndexChanging not handled

Scheduled Pinned Locked Moved ASP.NET
helpquestionworkspace
3 Posts 3 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.
  • M Offline
    M Offline
    MarkMokris
    wrote on last edited by
    #1

    I am using the following code to populate a GridView in protected void Button1_Click(object sender, EventArgs e) { String selectCommand = "select top 1000 claimid, formtype, status, totalpaid, paiddate from claim"; SqlDataAdapter ad = new SqlDataAdapter(selectCommand, SqlDataSource1.ConnectionString); DataTable dt = new DataTable(); ad.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } This works, but I have AllowPaging = true, and the first time I click the "Next Page" button, I get a "PageIndexChanging not handled" exception. I have not setup a PageIndexChanging handler, but I didn't think I had to in this case. BTW, when I populate by just setting the GridView1.DataSourceID to a SQLDataSource, the problem does not occur. Paging works fine. What am I doing wrong? Thanks! Mark

    S P 2 Replies Last reply
    0
    • M MarkMokris

      I am using the following code to populate a GridView in protected void Button1_Click(object sender, EventArgs e) { String selectCommand = "select top 1000 claimid, formtype, status, totalpaid, paiddate from claim"; SqlDataAdapter ad = new SqlDataAdapter(selectCommand, SqlDataSource1.ConnectionString); DataTable dt = new DataTable(); ad.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } This works, but I have AllowPaging = true, and the first time I click the "Next Page" button, I get a "PageIndexChanging not handled" exception. I have not setup a PageIndexChanging handler, but I didn't think I had to in this case. BTW, when I populate by just setting the GridView1.DataSourceID to a SQLDataSource, the problem does not occur. Paging works fine. What am I doing wrong? Thanks! Mark

      S Offline
      S Offline
      SayreCC
      wrote on last edited by
      #2

      Hi try this in your pageindexchanging event gridview.pageindex = e.newpageindex String selectCommand = "select top 1000 claimid, formtype, status, totalpaid, paiddate from claim"; SqlDataAdapter ad = new SqlDataAdapter(selectCommand, SqlDataSource1.ConnectionString); DataTable dt = new DataTable(); ad.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind();

      Hope this one can help. Thanks Hi, Please select Good Question if my answer are fit to your Question.

      1 Reply Last reply
      0
      • M MarkMokris

        I am using the following code to populate a GridView in protected void Button1_Click(object sender, EventArgs e) { String selectCommand = "select top 1000 claimid, formtype, status, totalpaid, paiddate from claim"; SqlDataAdapter ad = new SqlDataAdapter(selectCommand, SqlDataSource1.ConnectionString); DataTable dt = new DataTable(); ad.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } This works, but I have AllowPaging = true, and the first time I click the "Next Page" button, I get a "PageIndexChanging not handled" exception. I have not setup a PageIndexChanging handler, but I didn't think I had to in this case. BTW, when I populate by just setting the GridView1.DataSourceID to a SQLDataSource, the problem does not occur. Paging works fine. What am I doing wrong? Thanks! Mark

        P Offline
        P Offline
        Perry Holman
        wrote on last edited by
        #3

        You are binding the DataSource manually, so in this case you have to override the PageIndexChanging and PageIndexChanged handler. For example, protected void GridViewXXX_PageIndexChanged(object sender, EventArgs e) { this.SqlDataSourceXXX.SelectCommand = "XXX"; } protected void GridViewXXX_PageIndexChanging(object sender, GridViewPageEventArgs e) { this.GridViewXXX.PageIndex = e.NewPageIndex; }

        Welcome to www.softwaretree.net! This website is generated completely by static html pages transforming technology. You can find many excellent audio/video tools there!

        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