Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 4th, 2004, 02:20 AM
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default ListBox Problem


Am dynamically filling a ListBox with values from backend.

Please go thro the following sample code:

ListBox1.Items.Add(New ListItem("text1", "value1"))
ListBox1.Items.Add(New ListItem("text2", "value2"))
ListBox1.Items.Add(New ListItem("text3", "value3"))

I select the third item and click on the button.
The problem is: as soon as i click on the button,
the selection is lost and the first item is
selected.

I dont get this problem on using:
ListBox1.Items.Add("text1")

But i need to have the value property to identify
each listitem separately.

PLEASE NOTE that i have set AutoPostBack of Listbox
to false and EnableViewState to true.

Can someone please tell me why this happens?

:) Spacy


  #2 (permalink)  
Old October 17th, 2004, 03:49 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Can you provide more detail about how/when the add calls are running? Are you adding these to the list box every time or only on the first page hit (not ispostback)?
  #3 (permalink)  
Old October 18th, 2004, 05:45 AM
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Thanks a lot for replying planoie! Atlast a reply!

I have changed my logic to get rid of this problem. Am no longer
using: ListBox1.Items.Add(New ListItem("text1", "value1"))

But would still like to know why this is happening.
Well..am loading the listbox only in first page load
i.e. in !Page.IsPostBack

Thanks buddy!

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox Problem Brendan Bartley Access 4 November 26th, 2007 01:34 PM
ListBox problem aliirfan84 ASP.NET 2.0 Professional 5 May 28th, 2007 08:39 AM
listbox problem faizee36 Access VBA 4 April 27th, 2006 09:58 AM
A ListBox problem csc820203 C# 6 June 15th, 2004 06:45 PM



All times are GMT -4. The time now is 02:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.