2012-08-03 4 views
1
static public String Titl;  

이제 간단한 프로그래밍 언어로 내 양식에 드롭 다운 목록이 있다고 가정합니다. 나는 디버깅 때 드롭 다운 메뉴에서 선택된 값을 포함 드롭 다운 목록에서 선택된 값을 문자열 변수로 가져 오기 C#

dropdownlist1.text; 

쓸 때는 ID와 그 dropdownlist1 dropdowlist을 알았다. 그러나 내가 이런 일을했을 때 :

titl = dropdownlist1.text;  

나는 titl 변수에 값을 얻지 못했습니다. 도움이 필요하다. 고맙습니다! 당신이

title=dropdownlist1.selecteditem.text; 

하고있는 경우를 text..then하려면

+0

Shree Khanal : 그게 아무것도 해결하지 못할 것입니다 ... – Rupo

답변

2

확인이 당신이 값을 다음

title=dropdownlist1.selecteditem.value; 
0
Title = !string.IsNullorEmpty(dropdownlist1.SelectedItem.Text) ? 
dropdownlist1.SelectedITem.Text : ""; 
0
Titl = dropdownlist1.SelectedValue; 

작품을 원한다! 고맙습니다!

1
int selectedIndex=dropdownlist1.SelectedIndex;//get index 
string selectedText=dropdownlist1.SelectedItem.Text;//get text 
string selectedValue=dropdownlist1.SelectedItem.Value;//get value 
관련 문제