Hi,
I'm trying to read all the selected items in a ListBox. So after the user
selects the values they want in the ListBox they select a button. This is
where I want to put into a string all the values that were selected. The
ListBox is populated by a stored proc that reads a DB table. Yes, I have the
SelectionMode property set to MultiExtended, I have also tried MultiSimple.
I have seen some examples for ASP Web forms but I'm using Windows Forms
(Stand alone Application).
I have tried:
string msg = "";
for (int i = lstData.Items.C ount - 1; i >= 0; i--)
{
if(lstData.GetS elected(i) == true)
{
// do something here
}
}
In the // do something here part I have tried the following:
msg = lstData.Items[i].ToString(); - I get "Sytem.Data.Dat aRowView" string
for each Selected item in the ListBox
msg = lstData.Selecte dValue.ToString (); - This returns the correct value but
only for the first on and the same value is repeated. Does not work for the
second or greater value selected in ListBox.
I have tried others but these seemed the most promising. Please show me how
to read the Value of the ListBox for multiple selections. The Value I think
is what I want not the Displayed Text.
Any help would be greatly apprecaited,
Thanks,
-p 6 4156
On Aug 9, 8:07 am, "Pippen" <n...@valid.mai lwrote:
<snip>
In the // do something here part I have tried the following:
msg = lstData.Items[i].ToString(); - I get "Sytem.Data.Dat aRowView" string
for each Selected item in the ListBox
Instead of just calling ToString(), cast to a DataRowView and then
extract the part of the row that you're interested in.
Jon
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** **************@ r34g2000hsd.goo glegroups.com.. .
On Aug 9, 8:07 am, "Pippen" <n...@valid.mai lwrote:
<snip>
>In the // do something here part I have tried the following:
msg = lstData.Items[i].ToString(); - I get "Sytem.Data.Dat aRowView" string for each Selected item in the ListBox
Instead of just calling ToString(), cast to a DataRowView and then
extract the part of the row that you're interested in.
Jon
That worked great! Thank you for your help.
-p
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** **************@ r34g2000hsd.goo glegroups.com.. .
On Aug 9, 8:07 am, "Pippen" <n...@valid.mai lwrote:
<snip>
>In the // do something here part I have tried the following:
msg = lstData.Items[i].ToString(); - I get "Sytem.Data.Dat aRowView" string for each Selected item in the ListBox
Instead of just calling ToString(), cast to a DataRowView and then
extract the part of the row that you're interested in.
Jon
That worked great! Thank you for your help.
-p
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** **************@ r34g2000hsd.goo glegroups.com.. .
On Aug 9, 8:07 am, "Pippen" <n...@valid.mai lwrote:
<snip>
>In the // do something here part I have tried the following:
msg = lstData.Items[i].ToString(); - I get "Sytem.Data.Dat aRowView" string for each Selected item in the ListBox
Instead of just calling ToString(), cast to a DataRowView and then
extract the part of the row that you're interested in.
Jon
That worked great! Thank you for your help.
-p
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** **************@ r34g2000hsd.goo glegroups.com.. .
On Aug 9, 8:07 am, "Pippen" <n...@valid.mai lwrote:
<snip>
>In the // do something here part I have tried the following:
msg = lstData.Items[i].ToString(); - I get "Sytem.Data.Dat aRowView" string for each Selected item in the ListBox
Instead of just calling ToString(), cast to a DataRowView and then
extract the part of the row that you're interested in.
Jon
That worked great! Thank you for your help.
-p
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** **************@ r34g2000hsd.goo glegroups.com.. .
On Aug 9, 8:07 am, "Pippen" <n...@valid.mai lwrote:
<snip>
>In the // do something here part I have tried the following:
msg = lstData.Items[i].ToString(); - I get "Sytem.Data.Dat aRowView" string for each Selected item in the ListBox
Instead of just calling ToString(), cast to a DataRowView and then
extract the part of the row that you're interested in.
Jon
That worked great! Thank you for your help.
-p This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jen F. |
last post by:
I have inherited a medical database in which there are multiple values
stored in a single field (ie. "Current Conditions" field might contain
1-20 different conditions, separated by comma (ie. "Heart
Disease,Hyper Tyroid,Cancer" etc.
I would like to search via combo box for any one or more than one
value in this field, ie-what patients have Heart Disease or Cancer by
selecting these disorders off the combo box list.
Any help would be...
|
by: mike |
last post by:
How do i do the following:
lbCountries.SelectedValue = "826";
lbCountries.SelectedValue = "840";
Basically i've set the selectmode to multiple and want to select multiple
values of the listbox on databind.
the problem is this only selects the last row "840" -- i would imagine this
|
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 to highlight them in the
listbox within the datagrid control.........
Thanks,
Bill...
>-----Original Message-----
|
by: DC Gringo |
last post by:
I have two listboxes, the first of which is an autopostback=true that allows
multiple row selection. When I select multiple values (by holding down CTL)
in the first one, it should query the second one. I seem unable to do this
as it only sends back the first item I select whether I have the CTL key
down or not. Upon the return trip, I can select another one, but it still
only sends value for the last one I selected.
-- MY LISTBOX --...
|
by: ads |
last post by:
hi,
after binding the dropdownlist to a datasource, ive experience this error
"Cannot have multiple items selected in a dropdownlist" after using the code:
dropdownlist.items.findbyvalue("value").selected = true
I didnt specify any selected item in the dropdownlist during binding to the
datasource. I use dropdownlist.clearselection() but still error occurs.
I need information on this. Thanks.
Ads
| |
by: karups |
last post by:
Hi,
I've got listbox in my .aspx page where the users can make multiple
selection.
So, Users can select any number of items in listbox, I have to take
value from items and
pass it to stored procedure to extract a dataset back.
1.What should i do while passing the multiple selected values?
2.Can i use 'in' clause in SQL procedure like
|
by: Jay Ruyle |
last post by:
I'm trying to figure out a way to list several items in a listbox and let
the user select any number of items in the listbox. I have tried to code in
the items as bitwise items but all it stores in the database is the top item
in the listbox.
How can I get the listbox to add all the bit values to be stored and also
come out properly when viewed later?
Example:
|
by: billa856 |
last post by:
Hi,
My Project is in MS Access.
In that I have one form in which I have some textboxes,comboboxes and listboxes.
Now when I select value from 1st combobox(CustomerID) then it wil generate list for 1st listbox(PalletNo).
Now I want to select miltiple values from that 1st listbox(PalletNo).
and based upon this selection from 1st listbox(PalletNo) and combobox(CustomerID) I want to generate list for 2nd listbox(PONo).
For example
...
|
by: Eugenio |
last post by:
Hi there, I'm returning to this forum for the second time and I would like to say thanks for the great help provided. I've encountered a new problem now and hope that you will be able to help me again.
I'm currently implementing a container monitoring system in MSAccess07 and I'm using a multiple search function to sort containers. I use several unbound text boxes and a list box.The user type's in partial search criteria in one or several...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |