473,378 Members | 1,138 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,378 software developers and data experts.

Setting multiple items as selected in a ListBox with c#

I have a ListBox set as Multiselect. I am populating the table thruough asp.net code. But I am using another dataset to get the items that should be selected. The only item that ends up selected is the last item in the dataset. The code I am using for setting the selected items is:

DataSet ds1 = SqlHelper.ExecuteDataset(ConnStr, "StoredProd", Parm);

lbRequestTime.SelectionMode = ListSelectionMode.Multiple;

foreach (DataRow row in ds1.Tables[0].Rows)
{
lbRequestTime.SelectedValue = row["PerfTimeId"].ToString();
}

Any help on how to get the Mulitple selected items selected would be great.
Doug
Mar 24 '08 #1
0 1232

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: bill yeager | last post by:
Duray, it helps in regards to knowing how to get the items that were selected in the lisbox, but I'm going in reverse --- after I get the items from the db that were selected, I'd like to be able...
2
by: Peter | last post by:
Hello! Please, could anyone tell, is it possible to set multiple items to be selected in list control in the code? For example when the web form is loaded three items of 5 are selected in list...
5
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...
5
by: Paul | last post by:
Hi I have a listbox and have the selection mode set to multiple in the property box. I am trying to set multiple selected values in code but it only seems to use the last one....
1
by: sab | last post by:
Hi, We have a web form with a listbox. The listbox is a multiple select listbox and has data that looks something like: ALL Unit 1 Unit 2 Unit 3 Note: "ALL" is always the first item in...
3
by: Dany P. Wu | last post by:
Hi everyone, One of my Windows forms contain two listbox controls, with Add and Remove buttons between them. The idea is to allow users to select multiple items from one ListBox, click the...
2
by: Hitesh | last post by:
I have a listbox and the values get selected (highlighted) from code. I can highlight the corresponding list box items, but they do not show in the listbox I have to scroll through the list box to...
9
by: Bob Malcoprs | last post by:
Hi, I want to get all the selected values of a listbox in several labels.. With this code here below, when i click on e.g. "option 2", i get '2' in label2. That's ok. But if i then click on...
2
by: 6afraidbecause789 | last post by:
Hi - Has anyone ever used toggle buttons to select items in a listbox? I'd like to put about 24 toggle buttons on an unbound form that select or deselect items in a multiple select listbox. I've...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.