Re: Selected Item in ListBox
- From: Stan <google@xxxxxxxxxxxxxxx>
- Date: Sun, 30 Mar 2008 13:46:41 -0700 (PDT)
On 30 Mar, 19:07, EdwardH <Edwa...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I am filling a ListBox from a stored proc and a SQLDataReader which works fine.
Private pCateg As SqlCommand
Private pDR as Data.Sql.SqlDataReader
pCateg = New SqlCommand("pLodge")
pCateg.CommandType = Data.CommandType.StoredProcedure
pDR = pCateg.ExecuteReader
ListBox1.DataSource = pDR
ListBox1.DataTextField = "Category"
ListBox1.DataValueField = "Category"
ListBox1.Databind
I am trying to use the Value/Text of the Selected Item but am failing to get
that value which is coming back as a Null:
ListBox1. SelectedValue
How should I test that an Item has been selected and then get the value for
further use?
With thanks
You are using the wrong type of object as a DataSource (It should
throw an exception).
Recommend a DataSet (one created in the App_Code folder as an XSD
file). Create a TableAdapter that uses the "pLodge" stored procedure
as its select command.
.
- Follow-Ups:
- Re: Selected Item in ListBox
- From: EdwardH
- Re: Selected Item in ListBox
- From: EdwardH
- Re: Selected Item in ListBox
- References:
- Selected Item in ListBox
- From: EdwardH
- Selected Item in ListBox
- Prev by Date: Selected Item in ListBox
- Next by Date: Re: Selected Item in ListBox
- Previous by thread: Selected Item in ListBox
- Next by thread: Re: Selected Item in ListBox
- Index(es):
Relevant Pages
|