Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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 Display Modes
  #1 (permalink)  
Old December 14th, 2006, 07:21 PM
Friend of Wrox
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default Applying Multiple Selected Values to a Listbox

Hi All

I wonder if anyone can help provide a little guidance...

I have created a listbox that is populated using data from a SQL Server table. I have another table which is used for the selectedvalue property of my ListBox.

I seem to be having a problem with applying the selectedvalue as my code doesn't seem to let me apply more than one selected value though my listbox's ListSelectionMode is set to Multiple.

I think the problem is more to do with my logic applying the selected values for the listbox...

Say that I have already populated my listbox and have collected the data for the selectedvalue items, which are stored within a dataset called GenreTable... the code below is where I try to apply it to the selectedvalue property...

Dim i As Integer
For i = 0 To GenreTable.Tables("reporttbl").Rows.Count - 1
                ListGenre.SelectedValue = GenreTable.Tables("reporttbl").Rows(i)("genreID").ToString()
What it is doing is only applying the selected value of the last row item within my dataset.

Many thanks in advance

  #2 (permalink)  
Old December 15th, 2006, 06:12 AM
Friend of Wrox
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post

OK, after a sleepless night at the PC I have found an answer...

Selectedindex, selectedvalue and selecteditem do not work in Multiple selection mode. The following code works though...

           Dim i As Integer
            For i = 0 To GenreTable.Tables("reporttbl").Rows.Count - 1
                ListGenre.Items.FindByValue(GenreTable.Tables("rep orttbl").Rows(i)("genreID").ToString()).Selected = True


Thread Tools
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
(Chapter 6) applying user-selected theme in IE7 phoenixx ASP.NET 3.5 Basics 6 August 26th, 2008 09:49 AM
To highlight multiple selected values in listbox lily611 General .NET 7 August 20th, 2007 12:59 AM
multiple Listbox values in another listbox terryv Excel VBA 0 June 27th, 2007 07:01 AM
Get selected values from ListBox to DetailsView gerten ASP.NET 2.0 Professional 0 October 12th, 2006 01:21 PM
Listbox Selected values to be displayed on Submit dom1975 C# 0 September 17th, 2005 04:29 AM

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

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