473,804 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stuck with retrieving values from a listbox

Hello all. I'm new to .NET and I am stuck and I just cannot getthis to work (even after much searching).

I have a listbox populated by data from an Access Database. Themanner in which I fill the listbox is as follows:

\\\\\\\\
dsClosedPos.Cle ar()

dbAdapter.Selec tCommand = New OleDbCommand
dbAdapter.Selec tCommand.Connec tion = dbConnect
dbAdapter.Selec tCommand.Comman dText = _
"SELECT * FROM qryClosedOutPos itions"
dbAdapter.Selec tCommand.Comman dType = CommandType.Tex t

dbConnect.Open( )
dbAdapter.Selec tCommand.Execut eNonQuery()
dbAdapter.Fill( dsClosedPos, "ClosedPos" )
dbConnect.Close ()

lstClosedPos.Da taSource =dsClosedPos.Ta bles("ClosedPos ").DefaultV iew
lstClosedPos.Di splayMember = "TRADED"
\\\\\\

This populates the listbox (lostClosedPos) with the results fromthe query. I am tryint to retrieve the SelectedValue when auser makes a change. However, using something along the linesof lstClosedPos.Se lectedItem.Tost ring() orlstClosedPos. SelectedValue does not work. I need the value ofthe listbox selection as a variable for a query.

Any help would be appreciated.

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>FD3bt6WkBEW vgpEvqiDgpA==</Id>
Jul 21 '05 #1
2 1427
Hi,

Dim drv As DataRowView = ListBox1.Select edValue

Trace.WriteLine (drv.Item("TRAD ED").ToString )

Ken
-------------
"Alex A via .NET 247" <an*******@dotn et247.com> wrote in message
news:Od******** ******@TK2MSFTN GP11.phx.gbl...
Hello all. I'm new to .NET and I am stuck and I just cannot get this to
work (even after much searching).

I have a listbox populated by data from an Access Database. The manner in
which I fill the listbox is as follows:

\\\\\\\\
dsClosedPos.Cle ar()

dbAdapter.Selec tCommand = New OleDbCommand
dbAdapter.Selec tCommand.Connec tion = dbConnect
dbAdapter.Selec tCommand.Comman dText = _
"SELECT * FROM qryClosedOutPos itions"
dbAdapter.Selec tCommand.Comman dType = CommandType.Tex t

dbConnect.Open( )
dbAdapter.Selec tCommand.Execut eNonQuery()
dbAdapter.Fill( dsClosedPos, "ClosedPos" )
dbConnect.Close ()

lstClosedPos.Da taSource =
dsClosedPos.Tab les("ClosedPos" ).DefaultView
lstClosedPos.Di splayMember = "TRADED"
\\\\\\

This populates the listbox (lostClosedPos) with the results from the query.
I am tryint to retrieve the SelectedValue when a user makes a change.
However, using something along the lines of
lstClosedPos.Se lectedItem.Tost ring() or lstClosedPos.Se lectedValue does not
work. I need the value of the listbox selection as a variable for a query.

Any help would be appreciated.

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>FD3bt6WkBEW vgpEvqiDgpA==</Id>
Jul 21 '05 #2
Hi,

Dim drv As DataRowView = ListBox1.Select edValue

Trace.WriteLine (drv.Item("TRAD ED").ToString )

Ken
-------------
"Alex A via .NET 247" <an*******@dotn et247.com> wrote in message
news:Od******** ******@TK2MSFTN GP11.phx.gbl...
Hello all. I'm new to .NET and I am stuck and I just cannot get this to
work (even after much searching).

I have a listbox populated by data from an Access Database. The manner in
which I fill the listbox is as follows:

\\\\\\\\
dsClosedPos.Cle ar()

dbAdapter.Selec tCommand = New OleDbCommand
dbAdapter.Selec tCommand.Connec tion = dbConnect
dbAdapter.Selec tCommand.Comman dText = _
"SELECT * FROM qryClosedOutPos itions"
dbAdapter.Selec tCommand.Comman dType = CommandType.Tex t

dbConnect.Open( )
dbAdapter.Selec tCommand.Execut eNonQuery()
dbAdapter.Fill( dsClosedPos, "ClosedPos" )
dbConnect.Close ()

lstClosedPos.Da taSource =
dsClosedPos.Tab les("ClosedPos" ).DefaultView
lstClosedPos.Di splayMember = "TRADED"
\\\\\\

This populates the listbox (lostClosedPos) with the results from the query.
I am tryint to retrieve the SelectedValue when a user makes a change.
However, using something along the lines of
lstClosedPos.Se lectedItem.Tost ring() or lstClosedPos.Se lectedValue does not
work. I need the value of the listbox selection as a variable for a query.

Any help would be appreciated.

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>FD3bt6WkBEW vgpEvqiDgpA==</Id>
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
9656
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been made for service staff. My problem is the SQL is not retrieving the value of the listbox. I have tested the SQL by entering a fixed value of a valid entry in the listbox and it works fine, but as soon as I replace the fixed value with...
7
2583
by: Dave Hopper | last post by:
Hi I posted a question recently regarding problems I am having getting a value from a list box to use in a query. I got a lot of help, for which I thank you and it's nearly working! But I need a little more help on one more point. This is what i've got. I have code that hunts for updated appointments in a public folder based on the order that happens to be open (code fires on an on open event) This works fine and updates my
3
1711
by: Chris Thunell | last post by:
I have a Listbox on an vb aspx web page. When i select something in the listbox i do not get a selected value or selected index. The selected index is always -1. Any thoughts would be greatly appreciated! Chris Thunell cthunell@pierceassociates.com Here is my code: loading:
6
5228
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I have also tried changing the second ListBox to an HtmlSelect control) using bog standard JavaScript code like so where "used" is the name of my <select> control: used.options = new Option(name, typeId); This all works fine and I can move across...
2
1117
by: Jay Banks | last post by:
I'm working on a project that lists a few hundred items in a checked listbox. The listbox entries are all backed up by a structure, and only the descriptiong of the structure is shown in the listbox. Here's my structure: Public Structure ItemData Dim Descriptiong As String Dim Cost As Single Dim Quantity As Integer Dim Frequency As Single
3
3844
by: David L Wright II | last post by:
I have a data bound listbox that I want to select multiple lines then process each line. I bound a two column datatable to the listbox and set the DisplayMember property to the appropriate column of the datatable. I set the SelectionMode property to MultiExtended. I am able to load and select multiple lines in the listbox but I can not figure out how to retrieve both columns for each line selected in the listbox. I know that there is...
0
1691
by: Dave | last post by:
Hi all, I have a listbox that is complex bound by an arraylist. The problem is that when I delete an object from the arraylist, the listbox does not reflect those changes. I tried refreshing the listbox with no luck and, because it is already bound, I can't just delete the item directly from the listbox without an error (because it already has a datasource, you are not allowed to delete/add anything to the listbox directly). The...
1
336
by: Alex A via .NET 247 | last post by:
Hello all. I'm new to .NET and I am stuck and I just cannot getthis to work (even after much searching). I have a listbox populated by data from an Access Database. Themanner in which I fill the listbox is as follows: \\\\\\\\ dsClosedPos.Clear() dbAdapter.SelectCommand = New OleDbCommand dbAdapter.SelectCommand.Connection = dbConnect dbAdapter.SelectCommand.CommandText = _
0
1446
by: Phijo | last post by:
Hello, I'm a Java developer but brand new to ASP (i have done some of the tutorials) so I have some ASP programming background however I cannot find the cause or the fix to this problem. I am writing a web page in ASP (using C#) that needs to take data from a Database and put it into a ListBox, then have a button retrieve the selected item and then do some stuff. The problem I am having is retrieving the values in the ListBox. protected...
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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,...
0
10599
Oralloy
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...
1
10347
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,...
0
10090
tracyyun
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...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
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
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.