当前位置: 首页>>代码示例>>C#>>正文


C# DropDownList.SetValue方法代码示例

本文整理汇总了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;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:66,代码来源:AddressControl.cs


注:本文中的System.Web.UI.WebControls.DropDownList.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。