473,507 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web Form Listbox SelectedIndex Preservation

When I have a populated list box in a web form in VB under VS .Net 2003 and
then select an item by clicking it and then click a button to perform some
function based on the selected item I find that the selectedindex property
of the list box control is -1 ... indicating no item is selected ... and yet
one IS selected. I suspect this has something to do with page postbacks
but I would appreciate a explanation of what is happening here. Can I not
select and item and then preserve that selectedindex property across a click
of a button control?

Thanks very much.


Aug 19 '05 #1
2 1386
Fripper,

How did you fill that listbox, I tried it and had not any problem with what
you wrote.

I hope this helps,

Cor
Aug 19 '05 #2

Cor:

Problem solved ... thanks in large part to your question about how the list
box was filled. The code to populate the list box was in the load event
handler ... it first clears the list box and then loads it up. I had to
move that out of the load event handler and into the button click event
handler. I don't have a good handle on when pages are reloaded in .Net.

Thanks for your response.

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:e$*************@TK2MSFTNGP15.phx.gbl...
Fripper,

How did you fill that listbox, I tried it and had not any problem with
what you wrote.

I hope this helps,

Cor

Aug 19 '05 #3

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

Similar topics

2
2678
by: Laurent Bertin | last post by:
Hi i got a strange problem but it's true i don't make thing like anyone... First Config: + IIS5.0 SP2 (yes i know...) WebSite Security Root : Digest Authentication, NT Authenticated SubFolders...
2
13435
by: David Ichilov | last post by:
I've class derived from "Object" class, with ToString() method overriden itc. , now i add object of this class to Windows.Forms.ListBox.Items collection, and it works fine, displaying what...
3
4776
by: Joey | last post by:
Hi, I'm trying to add a default item to my listbox but when I do it tells me that it's not defined, could someone tell me the syntax I need to use to get the listbox control to display a default...
5
3513
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
1
1184
by: Alex Stevens | last post by:
Hi All, I've come across something which I think is a bug in the windows forms combobox and listboxes. I have a simple form which retrieves a datatable, and then set the datasource of a...
7
4518
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
2
354
by: fripper | last post by:
When I have a populated list box in a web form in VB under VS .Net 2003 and then select an item by clicking it and then click a button to perform some function based on the selected item I find...
1
2335
by: tony | last post by:
Hello!! Hello Victor! I use a product called flygrid to create grid tables. In many of my forms I create such grid tables. Some columns in these grid tables is of type drop down list where I...
2
4385
by: erbear | last post by:
Hi all, I am new to VB, and I am having some troubles. I have a listbox that when you click on the item it displays a picture in a picture box and a message in a label. It works fine when an item...
0
7114
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
7321
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
7377
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...
1
7034
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
7488
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
5623
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
5045
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...
0
3191
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
412
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.