Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'EnableViewState = false' of an asp.net DropDownList

If an asp.net DropDownList's is set to EnableViewState=false, DropDownList.SelectedItem returns null.

Then what technique can I use to get the SelectedItem of that DropDownList while keeping that EnableViewState=false?

like image 409
user366312 Avatar asked Dec 03 '22 07:12

user366312


1 Answers

Request.Form[yourDropDownList.UniqueID] 

UniqueID returns "ctl00$ContentMain$ddlCountry" where as ClientID returns "ctl00_ContentMain_ddlCountry"

The UniqueID is inserted to the name of the HTML form which is used in the postback form name.

like image 62
Jason Jong Avatar answered Dec 28 '22 16:12

Jason Jong