Parth
Parth

Reputation: 55

how to get the selected value of dropdown list of asp.net and store in session variable?

Dim ename As String = DropDownList.SelectedItem.Value

this statement is'nt working any help is appreciated!!

Upvotes: 3

Views: 44644

Answers (3)

Jorgesys
Jorgesys

Reputation: 126563

You need to store the value into a session variable, not only in a String variable:

Dim ename As String = DropDownList.SelectedItem.Value

Session("yourKey") = ename 

Upvotes: 0

user3100154
user3100154

Reputation: 1

I tried DropDownList.SelectedItem.ToString() & it worked. I tried without the parentheses too & it still work in visual basic. I hope it will work for you too.

Upvotes: 0

dcp
dcp

Reputation: 55467

I'm not sure if this is your problem, but if you're looking for the text of the item (instead of the value) you need DropDownList.SelectedItem.Text.

To store in session, you can just use

Session("yourKey") = DropDownList.SelectedItem.Value

Upvotes: 5

Related Questions