Problem with a drpdownlist in a datalist
-
I have some problems with a dropdownlist which is in a datalist. the dropdownlist is created statically and has only 4 items from 1 to 4, and it is in each row. when I get the dropdownlist selectedindex all of them just return the default value 0 even if user select another items!! :(( I use the following code to access the dropdownlist and the selectedindex
DropDownList drp= dstQuestions.Items[i].FindControl("DrpAnswer")as DropDownList ;
int answer = drp.SelectedIndex + 1;(dstQuestions is the name of the DataList.) answer always return 1 !! what is the problem?!
-
I have some problems with a dropdownlist which is in a datalist. the dropdownlist is created statically and has only 4 items from 1 to 4, and it is in each row. when I get the dropdownlist selectedindex all of them just return the default value 0 even if user select another items!! :(( I use the following code to access the dropdownlist and the selectedindex
DropDownList drp= dstQuestions.Items[i].FindControl("DrpAnswer")as DropDownList ;
int answer = drp.SelectedIndex + 1;(dstQuestions is the name of the DataList.) answer always return 1 !! what is the problem?!
Does your dropdown list has enable Postback. By default its false with DropdownList. So all the you are getting index as 0 which is the first index. Hope you got my point !:thumbsup:
Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips