M
Moe Sizlak
Hi There,
I am trying to write the selected value of a listcontrol when a button is
clicked and I keep getting the error "object not set to a reference of an
object". The libox itself is in a usercontrol and all i'm really needing to
do is get the selected value when the button is clicked on the form.
Can someone tell what I need to include in my page to get this working ?
Moe <><
!-- response.write
response.write (lstS.selectedItem.tostring())
response.end
!-- class function
Public Class CommonFunctions
Public Shared Function BindStates() as SqlDataReader
Dim myConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
Const strSQL as String = "SELECT LocationID, Location AS
Location " & _
"FROM tbLocation ORDER BY
Location"
Dim myCommand as New SqlCommand(strSQL, myConnection)
myConnection.Open()
Dim objDR as SqlDataReader
objDR = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Return objDr
End Function
End Class
!-- bind the contro
lstS.DataSource = CommonFunctions.BindStates
lstS.DataBind()
lstS.Items.Insert(0, new ListItem("By State","0"))
!- lisbox on page
<asp:listbox id="lstS" runat="server" rows=1
DataTextField="Location" DataValueField="LocationID"/>
I am trying to write the selected value of a listcontrol when a button is
clicked and I keep getting the error "object not set to a reference of an
object". The libox itself is in a usercontrol and all i'm really needing to
do is get the selected value when the button is clicked on the form.
Can someone tell what I need to include in my page to get this working ?
Moe <><
!-- response.write
response.write (lstS.selectedItem.tostring())
response.end
!-- class function
Public Class CommonFunctions
Public Shared Function BindStates() as SqlDataReader
Dim myConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
Const strSQL as String = "SELECT LocationID, Location AS
Location " & _
"FROM tbLocation ORDER BY
Location"
Dim myCommand as New SqlCommand(strSQL, myConnection)
myConnection.Open()
Dim objDR as SqlDataReader
objDR = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Return objDr
End Function
End Class
!-- bind the contro
lstS.DataSource = CommonFunctions.BindStates
lstS.DataBind()
lstS.Items.Insert(0, new ListItem("By State","0"))
!- lisbox on page
<asp:listbox id="lstS" runat="server" rows=1
DataTextField="Location" DataValueField="LocationID"/>