drpcken
Posts: 60
|
Posted: 08/20/2004, 3:12 PM |
|
I have 2 different types of controls...a dropdownlist and a multiselect listitem box, both of which are assigned a datasource, Text Column, and Binding Column.
When I'm working in the vb, and try to call these controls and use their properties, my build always tells me they arent declared... for instance i want to get the value of the dropdownlist which I named DropDownList1, when I try DropDownList1.SelectedItem.Text it always tells me that "DropDownList1 is not declared". It does this for EVERY single control I have that I write custom code for. This doesn't happen in my visual studio compiler, I'm confused as to how I go about getting this done. Here is my code...
Dim sTeamLeaderID, sCounselorID, sTeamLeaderName, sCounselorName As String
Dim sqlConn As New SqlClient.SqlConnection("server=(local); uid=sa; pw=;initial catalog=IFPAWEB")
Dim sqlInsertComm As SqlClient.SqlCommand
Dim sql As String
Dim i As Integer
sTeamLeaderName = DropDownList1.SelectedItem.Text
sTeamLeaderID = DropDownList1.SelectedItem.Value
Try
sqlConn.Open()
Finally
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).Selected Then
sCounselorID = ListBox1.Items(i).Value.ToString
sCounselorName = ListBox1.SelectedItem.Text
sql = "INSERT INTO teamleadercounselor (teamleaderid, teamleadername, counselorid, counselorname) values (" & sTeamLeaderID & ", " & sTeamLeaderName & ", " & _
sCounselorID & ", " & sCounselorName & ")"
With sqlInsertComm
.Connection = sqlConn
.CommandType = CommandType.Text
.CommandText = sql
.ExecuteScalar()
End With
End If
Next i
End Try
Thanks again!
|