473,467 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2392
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...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.