473,320 Members | 2,080 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,320 software developers and data experts.

ListBox Event - How Do I

I have a listbox, with a code behind on SelectedIndexChanged

This works well, except for one condition.

On returning to the listbox after PostBack, the previous selection is
still highlighted. This is how I want it as it tells the user, which
was his previous selection.

The problem i have, is that if the user reselects the previous
selection, which can be done for a valid reason, the
SelectedIndexChanged does not get called.

What property do I need to test, for in effect the selection click
event, rather than the indexchanged event, as I very much want to
retain the Previous Selected item.

I hope this is clear.

In other words how can I trap the selection, rather than the index
changing.

Thanks for all your previous help in the past - I am getting there - be
it rather slowly.

Richard

May 10 '06 #1
5 2066
Are you using AutoEventWireup ??

If yes, then there are no other events....

But u can try catching the event in Javascript and then firing the
event from the script....

Again , I am not sure whether JS catches the event as not done in
ASP.NET.....

U can give it a try....

May 10 '06 #2
Sorry to be so dumb, but what is AutoEventWireup - that is a new one
for my learning curve.

I am trying to avoid javascript at any event I am hoping my app will be
accessible, from a mobile browser and not all support javascript.

Thanks - Richard

May 10 '06 #3
That's how you trap the selection, by the index changing. That is only
wording, it's value, index, item all that changes.

Now, if the SelectedIndexChanged isn't firing when the user selects a
new item (it won't fire if the selection doesn't change between posts
to the server) then 1 of 2 things are happening. 1 the item hasn't
changed or 2, you are rebinding the list box on every post - which you
shouldn't do. Only rebind on the first post (Not IsPostBack) and
whenever the data source of the list box has changed.

-Rick

May 10 '06 #4
I will investigate further - I am probably binding on every postback,
as I am still trying to work out the event sequence for posting back.

Having progressed through all the getting started videos, it is
becoming more obvious that although all the goodie controls are nice,
when they come to real world datadriven applications, one ends up using
the lowest level control available.

As an aside can you recommend any article which differentiates, between
all the sqlClient classes. As I am getting confused as to which is the
best approach, bearing in mind my desire to have efficient access and
avoid unnecessary trips to the server . ( A long time ago an assembly
language programmer - so efficiency is tattooed on my forehead)

Thanks again - Richard

May 10 '06 #5
If the index isn't changing, I was assume you'd have to catch the onclick
event from the client-side and initiate the postback from there.

"mosscliffe" <pa***********@googlemail.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
I have a listbox, with a code behind on SelectedIndexChanged

This works well, except for one condition.

On returning to the listbox after PostBack, the previous selection is
still highlighted. This is how I want it as it tells the user, which
was his previous selection.

The problem i have, is that if the user reselects the previous
selection, which can be done for a valid reason, the
SelectedIndexChanged does not get called.

What property do I need to test, for in effect the selection click
event, rather than the indexchanged event, as I very much want to
retain the Previous Selected item.

I hope this is clear.

In other words how can I trap the selection, rather than the index
changing.

Thanks for all your previous help in the past - I am getting there - be
it rather slowly.

Richard

May 10 '06 #6

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

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
3
by: CJM | last post by:
I would like to be able to use an autocompleting listbox - that is, one where you can select an item in the list by typing the first few characters; the standard IE listbox only responds to the...
5
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
8
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
8
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
1
by: tony | last post by:
Hello! If you drag a ListBox into a windowform and then right click on this ListBox and then chose property. When you have the properties up click on the flash symbol for seeing all the events...
1
by: superjacent | last post by:
Hope someone can point me in the right direction. When opening a form the 'click' event of the ListBox is invoked (run). I thought the 'click' event of the ListBox is only invoked when clicking...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.