473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

losing selection from dropdownlist when paging

I have a search textbox for entering search value. I use with OnCommand event
in an ImageButton to set the SqlCommand string manually in the OnCommand
method.

When I click on a page number other than the first page the Gridview acts as
if the default SqlCommand was in being used and shows all rows instead of the
ones determined by a where clause. In other words, my custom SqlCommand is
not persisting when the Pager navigation is being used.

Any suggestions on how this should be handled would be appreciated.

Thanks.
Mar 30 '06 #1
3 2391
Are you re-binding the data every time the PAgeLoad event occurs, have you
tried putting the initial databinding in a if (!IsPostBack) condtion.

"Dabbler" wrote:
I have a search textbox for entering search value. I use with OnCommand event
in an ImageButton to set the SqlCommand string manually in the OnCommand
method.

When I click on a page number other than the first page the Gridview acts as
if the default SqlCommand was in being used and shows all rows instead of the
ones determined by a where clause. In other words, my custom SqlCommand is
not persisting when the Pager navigation is being used.

Any suggestions on how this should be handled would be appreciated.

Thanks.

Mar 30 '06 #2
The OnCommand event of the button fires only once and sets the SqlCommand
during that one postback. You have to persist that search condition in the
Session object and reset it while handling the page.init if the Session
variable is not null.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I have a search textbox for entering search value. I use with OnCommand event
in an ImageButton to set the SqlCommand string manually in the OnCommand
method.

When I click on a page number other than the first page the Gridview acts as
if the default SqlCommand was in being used and shows all rows instead of the
ones determined by a where clause. In other words, my custom SqlCommand is
not persisting when the Pager navigation is being used.

Any suggestions on how this should be handled would be appreciated.

Thanks.

Mar 30 '06 #3

That's the ticket!

"Phillip Williams" wrote:
The OnCommand event of the button fires only once and sets the SqlCommand
during that one postback. You have to persist that search condition in the
Session object and reset it while handling the page.init if the Session
variable is not null.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I have a search textbox for entering search value. I use with OnCommand event
in an ImageButton to set the SqlCommand string manually in the OnCommand
method.

When I click on a page number other than the first page the Gridview acts as
if the default SqlCommand was in being used and shows all rows instead of the
ones determined by a where clause. In other words, my custom SqlCommand is
not persisting when the Pager navigation is being used.

Any suggestions on how this should be handled would be appreciated.

Thanks.

Mar 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sklett | last post by:
Hi- I'm a bit rusty cause it's been awhile since I've made an asp.net app, but here is what I want to do: single aspx page bound DropDownList w/ autopost back that holds names of customers...
4
by: Sandy | last post by:
Hello - Sorry to have posted this twice, but my question wasn't being answered and I think it might be because my subject wasn't clear. I have a datagrid and a dropdownlist (which is outside...
0
by: bryanp10 | last post by:
I have a DataList on my page which contains multiple DropDownLists. My page defaults to showing six rows in the DataList. I want the ability to dynamically add rows if needed. Right now I'm just...
1
by: Tim2Be | last post by:
Hi, Does anyone know how to create a paging drowpdownlist? What I mean is to create a dropdownlist that display all the paging such as Page 1, Page 2, Page24, ..., Page 56,... Thanks, Tim
0
by: Chris Zopers | last post by:
Hello, I have developed an ASP.NET page, with a dropdownlist and some textboxes. When a selection is made in the dropdownlist, some data is retrieved from a database and displayed in the...
0
by: Chris Zopers | last post by:
Hello, I have developed an ASP.NET page, with a dropdownlist and some textboxes. When a selection is made in the dropdownlist, some data is retrieved from a database and displayed in the...
1
by: Chris Zopers | last post by:
Hello, I have developed an ASP.NET page, with a dropdownlist and some textboxes. When a selection is made in the dropdownlist, some data is retrieved from a database and displayed in the...
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
12
by: Michael Lang | last post by:
I'm adding checkbox controls to a panel in a post back, I then have a second post back in which I attempt to process the checkbox controls however they seem to have disappeared off the panel. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.