Dropdown list value

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
 
J

JD

Thanks for the response, but the value for the EnableViewState was already
set to true. What else can I check?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top