473,508 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with ListBox.SelectedIndexChanged

I have a ListBox and a corresponding SelectedIndexChanged event and within
that event need to determine which item is selected, but it always comes
back as 0 (I'm not setting anything selected in my PageLoad). How can I get
the index of the item selected?

Keith
Nov 18 '05 #1
2 1598
where is your code?

lstName.SelectedItem.Value can give you the answer.

before do so, you should verify that user selected one item.

if ( lstName.SelectedItem != null )

I have a ListBox and a corresponding SelectedIndexChanged event and within
that event need to determine which item is selected, but it always comes
back as 0 (I'm not setting anything selected in my PageLoad). How can I get the index of the item selected?

Keith

Nov 18 '05 #2
Seems to work, thanks.

Keith

"Edward" <zi***@citiz.net> wrote in message
news:ea**************@TK2MSFTNGP12.phx.gbl...
where is your code?

lstName.SelectedItem.Value can give you the answer.

before do so, you should verify that user selected one item.

if ( lstName.SelectedItem != null )

I have a ListBox and a corresponding SelectedIndexChanged event and within that event need to determine which item is selected, but it always comes
back as 0 (I'm not setting anything selected in my PageLoad). How can I

get
the index of the item selected?

Keith


Nov 18 '05 #3

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

Similar topics

2
453
by: CW | last post by:
Yes, Autopostback is true, and it doesn't make an iota of difference at all. HTML snippet and code (behind) snippet is as below: <asp:dropdownlist id="ddlLoginType" runat="server" Width="163px"...
3
1856
by: Chris Newby | last post by:
I have a very simple custom control that derives from WebControls.Panel and implements INamingContainer. It appear that controls created as children of my custom control are having ViewState...
5
4396
by: Dave | last post by:
Hi All, I have a windows form that contains 2 listboxes and 2 buttons. The listbox on the right is populated by a database routine (This is the easy part). The listbox on the left is populated...
7
1689
by: Zorpiedoman | last post by:
I'm confused. I have a listbox. The DataSource is a DataTable based on a SQL Select Statement that includes a where clause. For example, "Select ID, FirstName, LastName From Employees where...
3
7746
by: Alec MacLean | last post by:
Hi everyone, I have a ComboBox that when changed, calls a method to change the content of a ListBox. I'm also using the Listbox's SelectedIndexChanged event to change other control values on...
4
1529
by: The Confessor | last post by:
I've nearly completed the migration of my first ListBox control to a ListView in detail view, and I'm only experiencing one problem: My ListBox.SelectedIndexChanged procedure began as follows: ...
2
2904
by: teo | last post by:
I have a Listbox, if I set EnableViewStarte = False the AutopostaBack fired by SelectedIndexChanged doesn't work. The 'SelectedIndexChanged' event should call
3
2817
by: martin1 | last post by:
Hi, All, I want user select first item (called All) in listbox, then all other items are selected by SetSelected method, but in loop (see code below) whenever going to SetSelected(), the...
9
3200
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)....
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
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,...
1
7038
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
7493
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
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.