Stuck with retrieving values from a listbox
From: Alex A via .NET 247 (anonymous_at_dotnet247.com)
Date: 04/30/04
- Previous message: Rasmus: "Re: .Net in XP"
- Next in thread: Ken Tucker [MVP]: "Re: Stuck with retrieving values from a listbox"
- Reply: Ken Tucker [MVP]: "Re: Stuck with retrieving values from a listbox"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 30 Apr 2004 13:28:04 -0700
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.Clear()
dbAdapter.SelectCommand = New OleDbCommand
dbAdapter.SelectCommand.Connection = dbConnect
dbAdapter.SelectCommand.CommandText = _
"SELECT * FROM qryClosedOutPositions"
dbAdapter.SelectCommand.CommandType = CommandType.Text
dbConnect.Open()
dbAdapter.SelectCommand.ExecuteNonQuery()
dbAdapter.Fill(dsClosedPos, "ClosedPos")
dbConnect.Close()
lstClosedPos.DataSource = dsClosedPos.Tables("ClosedPos").DefaultView
lstClosedPos.DisplayMember = "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.SelectedItem.Tostring() or lstClosedPos.SelectedValue 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>FD3bt6WkBEWvgpEvqiDgpA==</Id>
- Previous message: Rasmus: "Re: .Net in XP"
- Next in thread: Ken Tucker [MVP]: "Re: Stuck with retrieving values from a listbox"
- Reply: Ken Tucker [MVP]: "Re: Stuck with retrieving values from a listbox"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|