Click here to Skip to main content
15,113,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, I am trying to session the values that a user select from a dropdownlist to be displayed on a label field in another page.

However, i only manage to session the ID of the value in the table. I want the value to appear instead of the ID that it represents.

Any idea how i can change it to show the value instead of the ID?

This is a snippet of my code where user selects from 2 DropDownList under the SelectedIndexChanged method:

C#
int ddvalue = Convert.ToInt32(DropDownList1.SelectedItem.Value);
int ddvalue1 = Convert.ToInt32(DropDownList2.SelectedItem.Value);
           if (ddvalue == 1 && ddvalue1 == 1)
           {
               Label6.Text = "$500";
           }


the code above only allows me to session the ID of the value. How can i session the value from the dropdownlist instead?

Any help will be greatly appreciated!
Posted
Updated 24-Jun-13 5:45am
v2
Comments
ZurdoDev 24-Jun-13 10:45am
   
Get the selecteditem.text instead of .value.
Jerrell77 24-Jun-13 10:54am
   
so the session statement is Session["duration"] = this.DropDownList1.SelectedValue; ?
or is it Session["duration"] = this.DropDownList1.SelectedIndex; ?
ZurdoDev 24-Jun-13 11:00am
   
It is SelectedItem.Text. Refer to http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.dropdownlist.aspx or just use intellisense to find it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900