GetSelectedValue
public static string GetSelectedValue(this System.Web.UI.WebControls.DropDownList ddl) { return System.Web.HttpContext.Current.Request.Form[ddl.UniqueID]; }Example:
string sValue = ddlSampleDropDown.GetSelectedValue();
Description
Get the selected value of a DropDownList by returning the value stored in the forms collection. This allows you to turn EnableViewState off on a DropDownList and still easily retrieve the selected value
Details
- Author: Jeremy Chapman
- Submitted on: 3/18/2010 11:32:30 PM
- Language: C#
- Type: System.Web.UI.WebControls.DropDownList
- Views: 1880
Double click on the code to select all.