Reputation: 39
static public String Titl;
Now in simple programming language suppose i got a dropdown list on my form. when i debugged i found out that dropdowlist with the id dropdownlist1 when written
dropdownlist1.text;
contains the value i selected in the dropdown menu. However when i did something like this:
titl = dropdownlist1.text;
i was not getting the value in the titl variable. Help needed. Thank You!
Upvotes: 1
Views: 27566
Reputation: 2509
int selectedIndex=dropdownlist1.SelectedIndex;//get index
string selectedText=dropdownlist1.SelectedItem.Text;//get text
string selectedValue=dropdownlist1.SelectedItem.Value;//get value
Upvotes: 1
Reputation: 2439
Title = !string.IsNullorEmpty(dropdownlist1.SelectedItem.Text) ?
dropdownlist1.SelectedITem.Text : "";
Upvotes: 0
Reputation: 707
check this if you want text..then
title=dropdownlist1.selecteditem.text;
and if you want value then
title=dropdownlist1.selecteditem.value;
Upvotes: 3