TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Scott G
NA
103
7.8k
How do I move multiple selections from one ListBox to another?
Jul 23 2020 10:47 AM
I have two listboxes. The first is populated from an SQL table. I am trying to allow the user to select mutiple entried from the first box and move them to the second. I tried using the code below (which works fine when selecting a single item from the listbox) in the loop but it still selects only the first item and adds it for each selection I make. (ie. If I select statute 12345, 12346 and 12347 it adds 12345 3 times to the other listbox).
private
void
btnAddStat_Click(
object
sender, EventArgs e)
{
foreach
(var item
in
lstStatutes.SelectedItems)
{
DataRowView drvStatute = lstStatutes.SelectedItem
as
DataRowView;
string
stat =
string
.Empty;
if
(drvStatute !=
null
)
{
stat = drvStatute.Row[
"Statute"
]
as
string
;
lstSelStatutes.Items.Add(stat);
}
}
}
Reply
Answers (
2
)
Subquery returned more than 1 value This is not permitted ??
Bind Data from database in dropdown using entity framework asp.net