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. Help with viewstate and gridview

Help with viewstate and gridview

Scheduled Pinned Locked Moved ASP.NET
helpquestionwpfwcftutorial
8 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.
  • T Offline
    T Offline
    Thommie h
    wrote on last edited by
    #1

    Hi, I have a problem, i have a gridview populated with items and in the pager i have controls for previous and next and a dropdownlist that shows the total number of pages. I also have a search function to search for item. if i for exemple search for *egg* i get a number of results and the ddl is populated with total number of pages for the searchterm. but if i click on the button for "next" the search result disapear and i get all the pages back (because of the postback) but how do i do to keep the state of the ´search so that i can use the next and previous buttons and the ddl listing of pages, depending on the search? I have never used viewstate so if someone can explain it well for me i would appreciate it very much! How to write the code and implement it. I use nhibernate and custom binding/paging

    N D 2 Replies Last reply
    0
    • T Thommie h

      Hi, I have a problem, i have a gridview populated with items and in the pager i have controls for previous and next and a dropdownlist that shows the total number of pages. I also have a search function to search for item. if i for exemple search for *egg* i get a number of results and the ddl is populated with total number of pages for the searchterm. but if i click on the button for "next" the search result disapear and i get all the pages back (because of the postback) but how do i do to keep the state of the ´search so that i can use the next and previous buttons and the ddl listing of pages, depending on the search? I have never used viewstate so if someone can explain it well for me i would appreciate it very much! How to write the code and implement it. I use nhibernate and custom binding/paging

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      You need to persist the search criteria in some manner and use it when requering the database. If you are using a textbox to eneter search criteria then enable viewstate and retrieve it's value before querying the database. Along with the page and number fo rows to retrieve of cource. The builtin support for paging in the datagrid should handle this for you though.


      I know the language. I've read a book. - _Madmatt

      T 1 Reply Last reply
      0
      • N Not Active

        You need to persist the search criteria in some manner and use it when requering the database. If you are using a textbox to eneter search criteria then enable viewstate and retrieve it's value before querying the database. Along with the page and number fo rows to retrieve of cource. The builtin support for paging in the datagrid should handle this for you though.


        I know the language. I've read a book. - _Madmatt

        T Offline
        T Offline
        Thommie h
        wrote on last edited by
        #3

        yes i use a textbox, how do i retrieve it´s value? i said that i have no knowledge of the use of viewstate. SO i need 2 queries against the database? one to populate the gv with all content and then one under pageindexchanging where i use the search criteria?

        N 1 Reply Last reply
        0
        • T Thommie h

          yes i use a textbox, how do i retrieve it´s value? i said that i have no knowledge of the use of viewstate. SO i need 2 queries against the database? one to populate the gv with all content and then one under pageindexchanging where i use the search criteria?

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Thommie.h wrote:

          said that i have no knowledge of the use of viewstate

          Then I suggest you stop what you are doing and learn more about ASP.NET.

          Thommie.h wrote:

          SO i need 2 queries against the database?

          No. I suggest you also spend some time understanding SQL queries before continuing. Understanding the tools and technology you are attempting to use will save you (and us) headaches and fustration.


          I know the language. I've read a book. - _Madmatt

          T 1 Reply Last reply
          0
          • N Not Active

            Thommie.h wrote:

            said that i have no knowledge of the use of viewstate

            Then I suggest you stop what you are doing and learn more about ASP.NET.

            Thommie.h wrote:

            SO i need 2 queries against the database?

            No. I suggest you also spend some time understanding SQL queries before continuing. Understanding the tools and technology you are attempting to use will save you (and us) headaches and fustration.


            I know the language. I've read a book. - _Madmatt

            T Offline
            T Offline
            Thommie h
            wrote on last edited by
            #5

            you are not helping me here, if you can explain a little as i asked from the beginning it would have helped or hint me somewhere.

            N 1 Reply Last reply
            0
            • T Thommie h

              you are not helping me here, if you can explain a little as i asked from the beginning it would have helped or hint me somewhere.

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              And what good would it do? You don't understand the concepts, tools, or technology. You have all the help and hints you need. Go read.


              I know the language. I've read a book. - _Madmatt

              T 1 Reply Last reply
              0
              • N Not Active

                And what good would it do? You don't understand the concepts, tools, or technology. You have all the help and hints you need. Go read.


                I know the language. I've read a book. - _Madmatt

                T Offline
                T Offline
                Thommie h
                wrote on last edited by
                #7

                and you cant write a understanding answear

                1 Reply Last reply
                0
                • T Thommie h

                  Hi, I have a problem, i have a gridview populated with items and in the pager i have controls for previous and next and a dropdownlist that shows the total number of pages. I also have a search function to search for item. if i for exemple search for *egg* i get a number of results and the ddl is populated with total number of pages for the searchterm. but if i click on the button for "next" the search result disapear and i get all the pages back (because of the postback) but how do i do to keep the state of the ´search so that i can use the next and previous buttons and the ddl listing of pages, depending on the search? I have never used viewstate so if someone can explain it well for me i would appreciate it very much! How to write the code and implement it. I use nhibernate and custom binding/paging

                  D Offline
                  D Offline
                  doudoufly
                  wrote on last edited by
                  #8

                  hi, you can store the search parameters into viewstate when you click on the button for "next", you needs rebind the data. you can also store the search parameters and page information in url like this: http://search.aspx?parameter=egg&page=1 my english is not very well, can u teach me english ? haha~ my msn :fly1126@live.cn

                  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