Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2006, 08:21 PM
Friend of Wrox
 
Join Date: Oct 2005
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...

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

Many thanks in advance

Rit
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
 
Old December 15th, 2006, 07:12 AM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

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
            Next

Rit





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





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