GetSelectedValue
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
Source
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();
Author: Jeremy Chapman
Submitted on: 18 mrt. 2010
Language: C#
Type: System.Web.UI.WebControls.DropDownList
Views: 4499