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 in a grid view troubles

Paging in a grid view troubles

Scheduled Pinned Locked Moved ASP.NET
databasecsssql-serversysadminhelp
3 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.
  • S Offline
    S Offline
    Senseicads
    wrote on last edited by
    #1

    I am currently having a few problems with a grid view I am working with. The gridview is set up to display a list of calls that have been received. This is populated via a view on the sql server database. I have a number of options on the page that I can filter the gridview on. The ides is that the user can click on a dropdown list and select some options and then click a button ‘apply’ which then composes a new query I then set this string (msg) to be the select command of the gridview using… sqlGridView.SelectCommand = "SELECT * FROM [uvw_supportcalllist] " & msg GridView1.DataBind() This applys the filter brilliantly…all is well and good so far. However I have set the paging attributes to true and set the pages length thing to be 20 now if I apply my filter like above and then go to the next page I lose my applied filter. I realise I am missing something somewhere, I have attempted to call databind again in the paging event of the page but that doesn’t work. Can someone help me out? Am I applying my filter wrongly? Or is there a better of paging the gridview? Any help would be most appreciated. Cheers Ian Caddick

    K 1 Reply Last reply
    0
    • S Senseicads

      I am currently having a few problems with a grid view I am working with. The gridview is set up to display a list of calls that have been received. This is populated via a view on the sql server database. I have a number of options on the page that I can filter the gridview on. The ides is that the user can click on a dropdown list and select some options and then click a button ‘apply’ which then composes a new query I then set this string (msg) to be the select command of the gridview using… sqlGridView.SelectCommand = "SELECT * FROM [uvw_supportcalllist] " & msg GridView1.DataBind() This applys the filter brilliantly…all is well and good so far. However I have set the paging attributes to true and set the pages length thing to be 20 now if I apply my filter like above and then go to the next page I lose my applied filter. I realise I am missing something somewhere, I have attempted to call databind again in the paging event of the page but that doesn’t work. Can someone help me out? Am I applying my filter wrongly? Or is there a better of paging the gridview? Any help would be most appreciated. Cheers Ian Caddick

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      I am guessing there is a pretty good chance that you are doing an initial load in the page load event? If you have code like that you need to check to see if the page load is a postback or not. You would only want to call that code on the first page load, not on a post back which is what happens when you page. So check the IsPostback property of the page. You code would be something like: If (!IsPostBack) { //Initial bind code here } Hope that helps. Ben

      S 1 Reply Last reply
      0
      • K kubben

        I am guessing there is a pretty good chance that you are doing an initial load in the page load event? If you have code like that you need to check to see if the page load is a postback or not. You would only want to call that code on the first page load, not on a post back which is what happens when you page. So check the IsPostback property of the page. You code would be something like: If (!IsPostBack) { //Initial bind code here } Hope that helps. Ben

        S Offline
        S Offline
        Senseicads
        wrote on last edited by
        #3

        Thanks but no, I already do that I am in vb but its the same thing I do Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack() Then Initialise() End If End Sub Thanks for trying tho Cheers Cads

        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