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

selectedindex value not being updated

I have a listbox whose autopostback property is set
to 'true'. When this event fires, I have code in
the 'SelectedIndexChanged' event to capture the
selectedindex of the listbox to be reset on the listbox
when the postback occurs. However, the selectedindex
property is alway -1.

Below is the code prior to selecting an item for this
listbox. Right after I select an item, the following code
executes, which I'm expecting, but
the "lstRider.SelectedIndex" value is -1, and I don't know
why.......
<code>
Private Sub lstRider_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
lstRider.SelectedIndexChanged

viewstate.Item("Rider1Idx") =
lstRider.Items.Item(lstRider.SelectedIndex).Value( )

End Sub
</code>

Can anybody inform me how I can capture the index of the
selected item in the list???
Nov 17 '05 #1
1 1383
maybe you are binding the listbox each time that the page is loaded.... you
can control it using Page.IsPostBack..

If Not Page.IsPostBack Then
BindListBox()
End If

public sub BindListBox()
' code to bind the listbox
end sub

"bill yeager" <ws********@msn.com> wrote in message
news:08****************************@phx.gbl...
I have a listbox whose autopostback property is set
to 'true'. When this event fires, I have code in
the 'SelectedIndexChanged' event to capture the
selectedindex of the listbox to be reset on the listbox
when the postback occurs. However, the selectedindex
property is alway -1.

Below is the code prior to selecting an item for this
listbox. Right after I select an item, the following code
executes, which I'm expecting, but
the "lstRider.SelectedIndex" value is -1, and I don't know
why.......
<code>
Private Sub lstRider_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
lstRider.SelectedIndexChanged

viewstate.Item("Rider1Idx") =
lstRider.Items.Item(lstRider.SelectedIndex).Value( )

End Sub
</code>

Can anybody inform me how I can capture the index of the
selected item in the list???

Nov 17 '05 #2

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

Similar topics

2
by: ross kerr | last post by:
Hi all, I have a control that extends the ComboBox object. It updates the selected item based on what the user enters in the text area. In the OnLeave event of the combobox, the selected...
1
by: Wanda | last post by:
Hi, I am trying to read the DropDownList's selectedIndex when it fires the event "SelectedIndexChanged", however, the index value is always 0 no matter what I've clicked. I just wonder what...
3
by: Angel | last post by:
I have a problem I placed a DropDown list control on my .NET page. I do not want to perform a postback when something is selected. When I want to get what was selected in the Client Script I do not...
2
by: John Blair | last post by:
Hi, I have a dropdownlist in a grid header template - i have autopostback on but when i check the selectedindex in the page_load event (i have a routine which identifies the control that caused...
3
by: Nathan Sokalski | last post by:
I am working on a simple user control composed of 3 DropDownLists that will be used to select Dates. The purpose of the control is to all the user to choose a date using dropdown lists but not need...
1
by: Nathan Sokalski | last post by:
I have a problem that is driving me crazy. I have a User Control composed of three DropDownLists that will be used to select a date. I have everything working except for one thing. When I select a...
6
by: Nathan Sokalski | last post by:
I am writing a User Control that uses 3 DropDownLists. When I attempt to access the SelectedIndex property it incorrectly reports the value selected by the user. Why is this? Here is my code,...
3
by: Alec MacLean | last post by:
Hi, I have a couple of win forms where I am editing values that are stored in a SQL database. I'm using the listbox control to hold the data object each form interacts with. Each object is...
0
by: mcheng2 | last post by:
Dynamically added RadioButtonList with AutoPostBack = true. On the first postback, SelectedIndex is not updated. For example: SelectedIndex starts at -1. Click Radio #1, SelectedIndex = -1....
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?
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
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
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.