本文整理汇总了C#中System.Web.UI.WebControls.DropDownList.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DropDownList.SetValue方法的具体用法?C# DropDownList.SetValue怎么用?C# DropDownList.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.DropDownList
的用法示例。
在下文中一共展示了DropDownList.SetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateChildControls
/// <summary>
/// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
/// </summary>
protected override void CreateChildControls()
{
base.CreateChildControls();
Controls.Clear();
RockControlHelper.CreateChildControls( this, Controls );
_tbStreet1 = new TextBox();
Controls.Add( _tbStreet1 );
_tbStreet1.ID = "tbStreet1";
_tbStreet1.CssClass = "form-control";
this.RequiredFieldValidator.ControlToValidate = _tbStreet1.ID;
_tbStreet2 = new TextBox();
Controls.Add( _tbStreet2 );
_tbStreet2.ID = "tbStreet2";
_tbStreet2.CssClass = "form-control";
_tbCity = new TextBox();
Controls.Add( _tbCity );
_tbCity.ID = "tbCity";
_tbCity.CssClass = "form-control";
_tbCounty = new TextBox();
Controls.Add( _tbCounty );
_tbCounty.ID = "tbCounty";
_tbCounty.CssClass = "form-control";
_tbState = new TextBox();
Controls.Add( _tbState );
_tbState.ID = "tbState";
_tbState.CssClass = "form-control";
_ddlState = new DropDownList();
Controls.Add( _ddlState );
_ddlState.ID = "ddlState";
_ddlState.DataValueField = "Id";
_ddlState.CssClass = "form-control";
_tbPostalCode = new TextBox();
Controls.Add( _tbPostalCode );
_tbPostalCode.ID = "tbPostalCode";
_tbPostalCode.CssClass = "form-control";
_ddlCountry = new DropDownList();
Controls.Add( _ddlCountry );
_ddlCountry.ID = "ddlCountry";
_ddlCountry.DataValueField = "Id";
_ddlCountry.AutoPostBack = true;
_ddlCountry.SelectedIndexChanged += _ddlCountry_SelectedIndexChanged;
_ddlCountry.CssClass = "form-control";
string defaultCountry = GetDefaultCountry();
string defaultState = GetDefaultState();
BindCountries();
_ddlCountry.SetValue( defaultCountry );
BindStates( defaultCountry );
_ddlState.SetValue( defaultState );
_tbState.Text = defaultState;
}