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


C# WebControls.DropDownList类代码示例

本文整理汇总了C#中System.Web.UI.WebControls.DropDownList的典型用法代码示例。如果您正苦于以下问题:C# DropDownList类的具体用法?C# DropDownList怎么用?C# DropDownList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DropDownList类属于System.Web.UI.WebControls命名空间,在下文中一共展示了DropDownList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeDataCell

 protected override void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState)
 {
     DropDownList ddl = new DropDownList();
     ddl.Items.Add("");
     ddl.AppendDataBoundItems = true;
     if (!string.IsNullOrEmpty(this.DataSourceID) || null != this.DataSource)
     {
         if (!string.IsNullOrEmpty(this.DataSourceID))
         {
             ddl.DataSourceID = this.DataSourceID;
         }
         else
         {
             ddl.DataSource = this.DataSource;
         }
         ddl.DataTextField = this.DataTextField;
         ddl.DataValueField = this.DataValueField;
     }
     if (this.DataField.Length != 0)
     {
         ddl.DataBound += new EventHandler(this.OnDataBindField);
     }
     ddl.Enabled = false;
     if ((rowState & DataControlRowState.Edit) != DataControlRowState.Normal || (rowState & DataControlRowState.Insert) != DataControlRowState.Normal)
     {
         ddl.Enabled = true;
     }
     cell.Controls.Add(ddl);
 }
开发者ID:t1b1c,项目名称:lwas,代码行数:29,代码来源:DropDownListField.cs

示例2: BindDDL

 protected void BindDDL(DropDownList ddl,Dictionary<string,string> dict)
 {
     ddl.DataSource = dict;
     ddl.DataTextField = "Value";
     ddl.DataValueField = "Key";
     ddl.DataBind();
 }
开发者ID:srnpr,项目名称:srnprframework,代码行数:7,代码来源:DialogColumn.aspx.cs

示例3: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            uToolsCore.Authorize();

            DropDownList ddl = new DropDownList();
            ddl.CssClass = "logType";

            //log types
            ddl.Items.Add(new ListItem("All",""));
            foreach (var logType in Enum.GetValues(typeof(LogTypes)).Cast<LogTypes>())
            {
                ddl.Items.Add(new ListItem(logType.ToString(), Convert.ToInt32(logType).ToString()));
            }
            logTypes.Controls.Add(ddl);

            ddl = new DropDownList();
            ddl.Items.Add(new ListItem("All", ""));
            ddl.CssClass = "userName";

            foreach (User thisUser in umbraco.BusinessLogic.User.getAll())
            {
                ddl.Items.Add(new ListItem(thisUser.LoginName, thisUser.Id.ToString()));
            }
            userName.Controls.Add(ddl);
        }
开发者ID:kgiszewski,项目名称:uTools,代码行数:25,代码来源:log.aspx.cs

示例4: ChangeVisible

 private void ChangeVisible(int index, DropDownList dropDownList, TextBox txtBox)
 {
     if (index == 1)
         dropDownList.Style["visibility"] = "visible";
     if(index == 2)
         txtBox.Style["visibility"] = "visible";
 }
开发者ID:juliakolesen,项目名称:voobrazi.by,代码行数:7,代码来源:IndividualOrderControl.ascx.cs

示例5: Fillddl_noselect

 public void Fillddl_noselect(DropDownList ddl, DataTable mydt, string textField, string valueFeild)
 {
     ddl.DataSource = mydt;
     ddl.DataValueField = valueFeild;
     ddl.DataTextField = textField;
     ddl.DataBind();
 }
开发者ID:NetworksAuro,项目名称:Networks,代码行数:7,代码来源:CommonFun.cs

示例6: PopulateDropDownList

 private void PopulateDropDownList(DropDownList pdlist, DataTable pDataTable, String pstrDataMember, String pstrDataValueField)
 {
     pdlist.DataSource = pDataTable;
     pdlist.DataTextField = pstrDataMember;
     pdlist.DataValueField = pstrDataValueField;
     pdlist.DataBind();
 }
开发者ID:michael1995,项目名称:C-Sharp-Projects,代码行数:7,代码来源:Purchase.ascx.cs

示例7: CreateChildControls

        protected override void CreateChildControls()
        {
            var config = (TfsConfigurer)this.GetExtensionConfigurer();

            this.txtArtifactName = new ValidatingTextBox { DefaultText = "Same as project name" };
            this.txtTeamProject = new TeamProjectPicker(config);
            this.txtBuildDefinition = new BuildDefinitionPicker(config);
            this.txtTeamProject.SelectedIndexChanged += (s, e) => { this.txtBuildDefinition.TeamProject = this.txtTeamProject.SelectedValue; };
            this.ddlBuildNumber = new DropDownList
            {
                Items =
                {
                    new ListItem("allow selection at build time", string.Empty),
                    new ListItem("last succeeded build", "success"),
                    new ListItem("last completed build", "last")
                }
            };
            this.txtBuildNumberPattern = new ValidatingTextBox { Text = "_(?<num>[^_]+)$" };

            this.Controls.Add(
                new SlimFormField("Artifact name:", this.txtArtifactName),
                new SlimFormField("Team project:", this.txtTeamProject),
                new SlimFormField("Build definition:", txtBuildDefinition),
                new SlimFormField("Build number:", this.ddlBuildNumber),
                new SlimFormField("Capture pattern:", this.txtBuildNumberPattern)
                {
                    HelpText = "When importing a build, you can opt to use the TFS build number; however, because TFS build numbers "
                    + "can be 1,000 characters (or more), up to 10 characters must be extracted to fit the BuildMaster build number "
                    + "using a Regex capture group named \"num\". The default TFS Build Number Format is $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r); "
                    + " and thus the pattern _(?<num>[^_]+)$ will extract the date and revision."
                }
            );
        }
开发者ID:LimpingNinja,项目名称:bmx-tfs,代码行数:33,代码来源:TfsBuildImporterTemplateEditor.cs

示例8: FillDropDownList

 /// <summary>
 /// Fills dropdownlist list with data from dataSource     
 /// <param name="list"></param>
 /// <param name="dataSource"></param>
 /// <param name="needEmpty">Indicates if we have to add empty element to dropDownList</param>
 /// <param name="dataValueField">value</param>
 /// <param name="dataTextField">text</param>
 /// <param name="emptyText">displayed text in emptyElement </param>
 public void FillDropDownList(DropDownList list, IEnumerable dataSource, String dataValueField = "", String dataTextField = "", bool needEmpty = false, String emptyText = "")
 {
     //if string[,] array is datasource
     if(dataSource.GetType() == typeof(System.String[,]))
     {
         list.DataSource = dataSource;
     }
     else //if any List<object> is datasource
     {
         list.DataSource = dataSource;
     }
     //if value or text fields are identified
     if(!string.IsNullOrEmpty(dataValueField))
     {
         list.DataValueField = dataValueField;
     }
     if(!string.IsNullOrEmpty(dataTextField))
     {
         list.DataTextField = dataTextField;
     }
     list.DataBind();
     //if we have to add an empty element to dropDownList
     if(needEmpty)
     {
         list.Items.Insert(0, new ListItem(emptyText, Constants.EpmtyDDLValue));
     }
 }
开发者ID:RentPaymentOrganization,项目名称:RentPaymentRepo,代码行数:35,代码来源:RPBasePage.cs

示例9: View

        /// <summary>
        /// Initializes a new instance of the <see cref="View" /> class.
        /// </summary>
        protected View()
            : base(HtmlTextWriterTag.Div)
        {
            Presenter = new Presenter(this);
            _answerCountLabel = new Label()
            {
                Text = ResourceHelper.GetString("AnswerCountDropDownLabel")
            };

            _answerCountDropDown = new DropDownList()
            {
                AutoPostBack = true
            };

            QuestionComposerControl = new QuestionComposer()
            {
                QuestionLabelText = ResourceHelper.GetString("QuestionLabelText"),
                AnswerLabelText = ResourceHelper.GetString("AnswerLabelText"),
                FractionLabelText = ResourceHelper.GetString("FractionLabelText"),
                ValidatorErrorMessage = ResourceHelper.GetString("FractionValidatorErrorMessage"),
                IsVisibleLabelText = ResourceHelper.GetString("IsVisibleLabelText")
            };

            _generateXmlButton = new Button()
            {
                Text = ResourceHelper.GetString("GenerateXMLButtonText")
            };

            _generateXmlButton.Click += GenerateXmlButton_Click;
        }
开发者ID:camil666,项目名称:MoodleQuestions,代码行数:33,代码来源:View.cs

示例10: BindListItems_CodeMasterInfos_OnlyDesc

        /// <summary>
        /// 使用字碼主檔記錄綁定指定的下拉框的數據源的中文描述值
        /// </summary>
        /// <param name="ddlTarget">指定的下拉框控件</param>
        /// <param name="listCMT_MacType">字碼主檔記錄</param>
        /// <param name="idxEmptyItem">空值項的序號(小於0時不作添加)</param>
        public static void BindListItems_CodeMasterInfos_OnlyDesc(DropDownList ddlTarget, List<CodeMaster_cmt_Info> listCodeMaster, int idxEmptyItem)
        {
            if (ddlTarget == null)
            {
                return;
            }

            ddlTarget.Items.Clear();

            if (listCodeMaster != null && listCodeMaster.Count > 0)
            {
                for (int i = 0; i < listCodeMaster.Count; i++)
                {
                    if (idxEmptyItem == i)
                    {
                        AddDropDownListEmptyItem(ddlTarget);
                    }

                    ListItem itemType = new ListItem();
                    itemType.Text = listCodeMaster[i].cmt_cRemark;
                    itemType.Value = listCodeMaster[i].cmt_cRemark;
                    ddlTarget.Items.Add(itemType);
                }
            }
        }
开发者ID:Klutzdon,项目名称:PBIMSN,代码行数:31,代码来源:DataConverter.cs

示例11: BuildStudentProspectTable

        public static void BuildStudentProspectTable(Table table, string userId)
        {
            GroupService service = new GroupService();
            DataTable dtProspects = service.GetProspectiveStudentsData(userId);
            DataTable dtGroups = service.GetSupervisorOfData(userId);

            for (int i = 0; i < dtProspects.Rows.Count; i++)
            {
                DropDownList ddlGroupList = new DropDownList();
                ddlGroupList.DataSource = dtGroups;
                ddlGroupList.DataTextField = "GroupName";
                ddlGroupList.DataValueField = "GroupId";
                ddlGroupList.DataBind();
                ddlGroupList.Items.Insert(0, "Add a group");

                string name = dtProspects.Rows[i].ItemArray[0].ToString();
                string id = dtProspects.Rows[i].ItemArray[1].ToString();

                LinkButton b = new LinkButton();
                b.Text = name;
                b.CommandArgument = id;
                b.CommandName = name;

                TableRow row = new TableRow();
                TableCell cellProspects = new TableCell();
                TableCell cellGroups = new TableCell();

                cellProspects.Controls.Add(b);
                cellGroups.Controls.Add(ddlGroupList);
                row.Cells.Add(cellProspects);
                row.Cells.Add(cellGroups);
                table.Rows.Add(row);
            }
        }
开发者ID:JamesWClark,项目名称:Strikethrough,代码行数:34,代码来源:GroupFactory.cs

示例12: OnInit

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			_dlInstalledStores = new DropDownList();

			var chooseText = library.GetDictionaryItem("Choose");
			if (string.IsNullOrEmpty(chooseText))
			{
				chooseText = "Choose...";
			}

			_dlInstalledStores.Items.Add(new ListItem(chooseText, "0"));

			foreach (var store in StoreHelper.GetAllStores())
			{
				_dlInstalledStores.Items.Add(new ListItem(store.Alias, store.Id.ToString()));
			}

			if (_data.Value != null)
			{
				try
				{
					_dlInstalledStores.SelectedValue = _data.Value.ToString();
				}
				catch
				{
				}
			}

			if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_dlInstalledStores);
		}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:32,代码来源:StorePickerDataEditor.cs

示例13: OnInit

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			_dlShippingProviderTypes = new DropDownList();

			var shippingProviderTypePickupText = library.GetDictionaryItem("ShippingProviderTypePickup");
			if (string.IsNullOrEmpty(shippingProviderTypePickupText))
			{
				shippingProviderTypePickupText = "Pickup";
			}

			var shippingProviderTypeShippingText = library.GetDictionaryItem("ShippingProviderTypeShipping");
			if (string.IsNullOrEmpty(shippingProviderTypeShippingText))
			{
				shippingProviderTypeShippingText = "Shipping";
			}

			_dlShippingProviderTypes.Items.Add(new ListItem(shippingProviderTypePickupText, Common.ShippingProviderType.Pickup.ToString()));
			_dlShippingProviderTypes.Items.Add(new ListItem(shippingProviderTypeShippingText, Common.ShippingProviderType.Shipping.ToString()));

			_dlShippingProviderTypes.SelectedValue = _data.Value.ToString();

			if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_dlShippingProviderTypes);
		}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:25,代码来源:ShippingProviderTypeDataEditor.cs

示例14: InitializeSkin

        protected override void InitializeSkin(System.Web.UI.Control Skin)
        {
            KeyWords=(TextBox)Skin.FindControl("KeyWords");
            AllowPsd = (CheckBox)Skin.FindControl("AllowPsd");
            IsEnReply = (CheckBox)Skin.FindControl("IsEnReply");
            IsIndexShow = (CheckBox)Skin.FindControl("IsIndexShow");
            AllowPsd.Attributes.Add("onclick", "AllowPsd()");
            TextBox1 = (TextBox)Skin.FindControl("TextBox1");
            TextBox2 = (TextBox)Skin.FindControl("TextBox2");  //js把logId写入

            CreateTime = (TextBox)Skin.FindControl("CreateTime");
            if (!Page.IsPostBack)
            {
                CreateTime.Text = DateTime.Now.ToString();
            }

            LogIdTex = (TextBox)Skin.FindControl("LogId");//没有用到啊···
            Title = (TextBox)Skin.FindControl("title");
            Add = (Button)Skin.FindControl("Add");
            AddDraft = (Button)Skin.FindControl("AddDraft");
            Cansel = (Button)Skin.FindControl("Cansel");
            Editor = (TextBox)Skin.FindControl("txtContent");
            LogCategory = (DropDownList)Skin.FindControl("LogCategory");
            this.DataBind();
        }
开发者ID:LittlePeng,项目名称:ncuhome,代码行数:25,代码来源:AddLog.cs

示例15: CreateChildControls

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Label lblQuestion = new Label();
            _ddAnswer = new DropDownList();
            RequiredFieldValidator valQuestion = new RequiredFieldValidator();

            lblQuestion.ID = "lbl" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            _ddAnswer.ID = "dd" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            valQuestion.ID = "val" + _question.QuestionGuid.ToString().Replace("-", String.Empty);

            lblQuestion.Text = _question.QuestionText;
            lblQuestion.AssociatedControlID = _ddAnswer.ID;

            valQuestion.ControlToValidate = _ddAnswer.ID;
            valQuestion.Enabled = _question.AnswerIsRequired;

            _ddAnswer.Items.Add(new ListItem(Resources.SurveyResources.DropDownPleaseSelectText, String.Empty));

            foreach (QuestionOption option in _options)
            {
                ListItem li = new ListItem(option.Answer);
                if (li.Value == _answer) li.Selected = true;
                _ddAnswer.Items.Add(li);
            }

            valQuestion.Text = _question.ValidationMessage;

            Controls.Add(lblQuestion);
            Controls.Add(_ddAnswer);
            Controls.Add(valQuestion);
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:32,代码来源:DropDownListQuestion.cs


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