Dropdown list value

Discussion in 'ASP .Net Web Controls' started by JD, Jun 29, 2007.

  1. JD

    JD Guest

    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
     
    JD, Jun 29, 2007
    #1
    1. Advertising

  2. JD

    Raj Guest

    Set the EnableViewState="true" attribute for the drop down list.

    raj

    "JD" wrote:

    > 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
    >
    >
    >
     
    Raj, Jul 5, 2007
    #2
    1. Advertising

  3. JD

    JD Guest

    Thanks for the response, but the value for the EnableViewState was already
    set to true. What else can I check?
    "Raj" <> wrote in message
    news:...
    > Set the EnableViewState="true" attribute for the drop down list.
    >
    > raj
    >
    > "JD" wrote:
    >
    >> 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
    >>
    >>
    >>
     
    JD, Jul 5, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vishnu
    Replies:
    1
    Views:
    1,251
    Patrick.O.Ige
    Mar 25, 2006
  2. Mike
    Replies:
    1
    Views:
    846
  3. acadam
    Replies:
    0
    Views:
    785
    acadam
    Dec 27, 2006
  4. =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=

    Dropdown List - Check if value exists in list prior to selection

    =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=, Mar 10, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    2,015
    =?Utf-8?B?QnJlbmRlbg==?=
    Mar 20, 2007
  5. Replies:
    2
    Views:
    459
Loading...

Share This Page