Selected Item in ListBox

Tech-Archive recommends: Fix windows errors by optimizing your registry



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
.



Relevant Pages

  • Re: Selected Item in ListBox
    ... Have achieved the filling of the ListBox with a DataSet but still cannot get ... Private pCateg As SqlCommand ... Private pDR as Data.Sql.SqlDataReader ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Selected Item in ListBox
    ... "Stan" wrote: ... value back from ListBox using - "ListBox1.SelectedValue.ToString". ... Private pDR as Data.Sql.SqlDataReader ... populate the ListBox, make a selection in the browser, and then not ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Selected Item in ListBox
    ... value back from ListBox using - "ListBox1.SelectedValue.ToString". ... Private pDR as Data.Sql.SqlDataReader ... populate the ListBox, make a selection in the browser, and then not ... retrieve a selected value on postback. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Selected Item in ListBox
    ... I realise I need the continuity of a Dataset. ... "Stan" wrote: ... Private pCateg As SqlCommand ... Private pDR as Data.Sql.SqlDataReader ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Selected Item in ListBox
    ... Private pCateg As SqlCommand ... Private pDR as Data.Sql.SqlDataReader ... Create a TableAdapter that uses the "pLodge" stored procedure ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)