Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dropdown list value

Reply
Thread Tools

Dropdown list value

 
 
JD
Guest
Posts: n/a
 
      06-29-2007
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


 
Reply With Quote
 
 
 
 
Raj
Guest
Posts: n/a
 
      07-05-2007
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
>
>
>

 
Reply With Quote
 
 
 
 
JD
Guest
Posts: n/a
 
      07-05-2007
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:E9C66067-8EB5-4D7B-966F-...
> 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
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown List - Check if value exists in list prior to selection =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?= ASP .Net 5 03-20-2007 11:05 PM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
Re: need selected value from dropdown list box Scott Allen ASP .Net 1 08-25-2004 07:09 PM
Dropdown List Box - Adding an item value Brian Candy ASP .Net 2 02-20-2004 01:39 PM
Setting Value of Dropdown List from Array George ASP .Net 1 02-01-2004 06:36 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57