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 and Data Filtering.

Gridview Paging and Data Filtering.

Scheduled Pinned Locked Moved ASP.NET
helpcssquestion
4 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.
  • V Offline
    V Offline
    VikashGohil
    wrote on last edited by
    #1

    Hello, This is Vikash Gohil. I have a problem related to Gridview as mentioned below. I have a gridview page that displays All data from a table on page load. Now I have also provided Data Filtering options on the same page for filtering data that is displayed. Now when the user provides a filter condition, gridview only displays the filtered data. But once the user clicks on Next or Previous in the Gridview pager, the filter gets removed and the grid again displays all the data. What I want is the filter condition should remain until the user provides another condition for filtering. How can I go about doing this. Anyone can give me some idea. This would be of great help. Awaiting a reply, Thanks in Advance.

    S 1 Reply Last reply
    0
    • V VikashGohil

      Hello, This is Vikash Gohil. I have a problem related to Gridview as mentioned below. I have a gridview page that displays All data from a table on page load. Now I have also provided Data Filtering options on the same page for filtering data that is displayed. Now when the user provides a filter condition, gridview only displays the filtered data. But once the user clicks on Next or Previous in the Gridview pager, the filter gets removed and the grid again displays all the data. What I want is the filter condition should remain until the user provides another condition for filtering. How can I go about doing this. Anyone can give me some idea. This would be of great help. Awaiting a reply, Thanks in Advance.

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      VikashGohil wrote:

      But once the user clicks on Next or Previous in the Gridview pager, the filter gets removed and the grid again displays all the data.

      Make sure, you had put this in IsPostback condition. Might be grid is getting rebind with the data. Filter client side implemented or server side?

      V 1 Reply Last reply
      0
      • S Sandeep Mewara

        VikashGohil wrote:

        But once the user clicks on Next or Previous in the Gridview pager, the filter gets removed and the grid again displays all the data.

        Make sure, you had put this in IsPostback condition. Might be grid is getting rebind with the data. Filter client side implemented or server side?

        V Offline
        V Offline
        VikashGohil
        wrote on last edited by
        #3

        Hello, Sandeep. Thanks for the reply. I have Used an SQL DataSource to Bind Data to the Gridview. Initially I had written the Select Command for DataSource in Page_Load event as follows: Page_Load(...) if not page.Ispostback then SDS.ConnectionString = SDS.SelectCommand = GridView.DataSourceID="SDS" GridView.DataBind end if Now the problem here is when first time the page is loaded, the grid displays properly. But when the page postback happens the gridview disappears, bcoz there is no selectcommand in the DataSource. So I have to compulsorily write the above code as below. Page_Load(...) SDS.ConnectionString = SDS.SelectCommand = GridView.DataSourceID="SDS" GridView.DataBind if not page.Ispostback then end if And what do you mean by saying Filtering Client-Side or Server-Side, could you explain a bit about both types. Thanks in Advance, awaiting a reply soon.

        A 1 Reply Last reply
        0
        • V VikashGohil

          Hello, Sandeep. Thanks for the reply. I have Used an SQL DataSource to Bind Data to the Gridview. Initially I had written the Select Command for DataSource in Page_Load event as follows: Page_Load(...) if not page.Ispostback then SDS.ConnectionString = SDS.SelectCommand = GridView.DataSourceID="SDS" GridView.DataBind end if Now the problem here is when first time the page is loaded, the grid displays properly. But when the page postback happens the gridview disappears, bcoz there is no selectcommand in the DataSource. So I have to compulsorily write the above code as below. Page_Load(...) SDS.ConnectionString = SDS.SelectCommand = GridView.DataSourceID="SDS" GridView.DataBind if not page.Ispostback then end if And what do you mean by saying Filtering Client-Side or Server-Side, could you explain a bit about both types. Thanks in Advance, awaiting a reply soon.

          A Offline
          A Offline
          Arindam Tewary
          wrote on last edited by
          #4

          If you have a Next, Previous button you should be having PageIndexChange event for that GridView. In that event handler you need to "rebind" the data with filter condion that has already been selected. So you need to Save the select query too (using any session management technique ie. ViewState, Hidden field, session variable per your requirement. Hope this helps,

          Thanks, Arindam D Tewary

          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