J
JD
I want to capture values from dropdown lists and pass values as parameters
to stored procedure. I select a value in the dropdown list, when I click the
Submit Button the value disappears in the dropdown list and no value is
passed. I have tried using the ddl.selecteditem.value or text. I continue
to get no values.
If I use text boxes, everything works, but I need to restrict selections to
a specified list.
I'm new to web forms; I have no problem in Windows Forms.
Here is code. What is wrong and where can I find the answer? Thanks.
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim ConnStr As String = "packet size=4096;integrated security=SSPI;data
source=(local);persist security info=False;initial catalog=SSNew1"
Dim Cn As New SqlClient.SqlConnection(ConnStr)
Dim cmdGetAccessData As New SqlClient.SqlCommand
cmdGetAccessData.Connection = Cn
cmdGetAccessData.CommandType = CommandType.StoredProcedure
cmdGetAccessData.CommandText = "usp_GetDataforAccess"
Dim param1 As New SqlClient.SqlParameter("@Drainage",
ddDrainage.SelectedItem.Text)
Dim param2 As New SqlClient.SqlParameter("@Region",
ddRegion.SelectedItem.Text)
Dim param3 As New SqlClient.SqlParameter("@SurveyYear", txtYear.Text)
param1.Value = Me.ddDrainage.SelectedItem.Text
cmdGetAccessData.Parameters.Add(param1)
cmdGetAccessData.Parameters.Add(param2)
cmdGetAccessData.Parameters.Add(param3)
cmdGetAccessData.Connection.Open()
cmdGetAccessData.ExecuteNonQuery()
End Sub
to stored procedure. I select a value in the dropdown list, when I click the
Submit Button the value disappears in the dropdown list and no value is
passed. I have tried using the ddl.selecteditem.value or text. I continue
to get no values.
If I use text boxes, everything works, but I need to restrict selections to
a specified list.
I'm new to web forms; I have no problem in Windows Forms.
Here is code. What is wrong and where can I find the answer? Thanks.
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim ConnStr As String = "packet size=4096;integrated security=SSPI;data
source=(local);persist security info=False;initial catalog=SSNew1"
Dim Cn As New SqlClient.SqlConnection(ConnStr)
Dim cmdGetAccessData As New SqlClient.SqlCommand
cmdGetAccessData.Connection = Cn
cmdGetAccessData.CommandType = CommandType.StoredProcedure
cmdGetAccessData.CommandText = "usp_GetDataforAccess"
Dim param1 As New SqlClient.SqlParameter("@Drainage",
ddDrainage.SelectedItem.Text)
Dim param2 As New SqlClient.SqlParameter("@Region",
ddRegion.SelectedItem.Text)
Dim param3 As New SqlClient.SqlParameter("@SurveyYear", txtYear.Text)
param1.Value = Me.ddDrainage.SelectedItem.Text
cmdGetAccessData.Parameters.Add(param1)
cmdGetAccessData.Parameters.Add(param2)
cmdGetAccessData.Parameters.Add(param3)
cmdGetAccessData.Connection.Open()
cmdGetAccessData.ExecuteNonQuery()
End Sub