473,379 Members | 1,201 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Error Event 'lstS_SelectedValueChanged' cannot be found. when trying to get value from listbox control

Hi There,

I am trying to get the value from a listbox, I have a class in my code
behind page and I have created a sub to try to capture the selected value of
the listbox but it keeps giving me an error 'Event
lstS_SelectedValueChanged' cannot be found. What am I doing wrong?

Moe
!---page code

<%@Page language="vb" inherits="CommonFunctions" src="Default.vb" %>
<form runat="server">

<script language="vb" runat="server">
Sub Page_Load(byVal obj As Object, byVal e As EventArgs)
If Not Page.IsPostBack Then
lstS.DataSource = CommonFunctions.BindStates
lstS.DataBind()
lstS.Items.Insert(0, new ListItem("By State","0"))
End If
End Sub
</script>

<asp:listbox id="lstS" runat="server" Rows="1" AutoPostBack="true"
DataTextField="Location" DataValueField="LocationID"
SelectedValueChanged="lstS_SelectedValueChanged"/>

<asp:TextBox id="txt1" width="40" maxlength= "40"
runat="server" />
</form>
!--- code behind page code

imports system
imports system.web
imports System.Configuration
imports system.web.ui
imports system.web.ui.webcontrols
imports system.web.ui.htmlcontrols
imports system.data
imports system.data.sqlclient
imports system.data.sqlclient.sqldatareader

Public Class CommonFunctions
Inherits System.web.ui.page
'Inherits System.Web.UI.UserControl
Protected WithEvents lstS As ListBox

public txt1 as Textbox
Public Shared Function BindStates() as SqlDataReader

Dim myConnection as New
SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))
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.CloseConne ction)
Return objDr
End Function

Public Sub lstS_SelectedValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lstS.SelectedValueChanged
If lstS.SelectedIndex <> -1 Then
txt1.Text = lstS.SelectedValue
End If
End Sub
End Class
Nov 18 '05 #1
0 1113

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

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
2
by: JoeHenrich | last post by:
I am using VS.NET 2003 and am having an interesting issue with a Listbox control. Essentially, I have a form with a listbox on it. In the listbox doubleclick event I would like to do some...
2
by: Kris Vanherck | last post by:
yesterday i started getting this strange error when i try to run my asp.net project: Compiler Error Message: CS0006: Metadata file 'c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
6
by: kimiraikkonen | last post by:
Hello, I have a listbox and folder browser control. I need to display all .mp3 files' pathes into listbox. It was Ok with openfiledialog but how can list all .mp3 extension- having files into...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
6
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.