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