ListBox Event - How Do I

M

mosscliffe

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
 
J

jimmy

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....
 
M

mosscliffe

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
 
R

Rick

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
 
M

mosscliffe

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
 
G

Greg Hill

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top