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


C# DropDownList.ClearSelection方法代码示例

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


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

示例1: SelectItem

 public static void SelectItem(DropDownList control, string value)
 {
     control.ClearSelection();
     ListItem item = control.Items.FindByValue(value);
     if (item != null)
         item.Selected = true;
 }
开发者ID:williamesharp,项目名称:Aspose_Email_NET,代码行数:7,代码来源:WebUtil.cs

示例2: SetSelectedItem

 /// <summary>
 /// 设置下拉框选中
 /// </summary>
 /// <param name="dropDownList">drop</param>
 /// <param name="value">选中值</param>
 public static void SetSelectedItem(DropDownList dropDownList, string value)
 {
     ListItem item = dropDownList.Items.FindByValue(value);
     if (item != null)
     {
         dropDownList.ClearSelection();
         item.Selected = true;
     }
 }
开发者ID:naishengbiao,项目名称:Simple.Framework,代码行数:14,代码来源:BaseUtil.cs

示例3: DropDownListSelect

 public static void DropDownListSelect(ref DropDownList ddl, string value)
 {
     ddl.ClearSelection();
     ListItem li = ddl.Items.FindByValue(value);
     if (li != null)
     {
         li.Selected = true;
     }
 }
开发者ID:nicholaswilliambrown,项目名称:ProfilesRNS_ORCID,代码行数:9,代码来源:UICommon.cs

示例4: LoadParentDropDown

 private void LoadParentDropDown(DropDownList ddl, Category self)
 {
     // Load up the Parent DropDown
     ddl.ClearSelection();
     ddl.Items.Add(new ListItem("none", "0"));
     foreach (Category cat in Category.Categories)
     {
         if (self == null || !cat.Id.Equals(self.Id))
             ddl.Items.Add(new ListItem(cat.CompleteTitle(), cat.Id.ToString()));
     }
 }
开发者ID:sagasu,项目名称:tddLegacy,代码行数:11,代码来源:Categories.aspx.cs

示例5: SetSelectedValue

        /// <summary>
        /// Selects the item in the list control that contains the specified value, if it exists.
        /// </summary>
        /// <param name="dropDownList"></param>
        /// <param name="selectedValue">The value of the item in the list control to select</param>
        /// <returns>Returns true if the value exists in the list control, false otherwise</returns>
        public static bool SetSelectedValue(DropDownList dropDownList, String selectedValue)
        {
            dropDownList.ClearSelection();

            ListItem selectedListItem = dropDownList.Items.FindByValue(selectedValue);

            if(selectedListItem != null)
            {
                selectedListItem.Selected = true;
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:KGAD,项目名称:mixerp,代码行数:22,代码来源:DropDownListHelper.cs

示例6: RenderEditMode

        /// <Summary>RenderEditMode renders the Edit mode of the control</Summary>
        /// <Param name="writer">A HtmlTextWriter.</Param>
        protected override void RenderEditMode( HtmlTextWriter writer )
        {
            PortalSettings _portalSettings = Globals.GetPortalSettings();

            //For convenience create a DropDownList to use
            DropDownList cboTimeZones = new DropDownList();

            //Load the List with Time Zones
            Localization.LoadTimeZoneDropDownList(cboTimeZones, ((PageBase)Page).PageCulture.Name, Convert.ToString(_portalSettings.TimeZoneOffset));

            //Select the relevant item
            if (cboTimeZones.Items.FindByValue(StringValue) != null)
            {
                cboTimeZones.ClearSelection();
                cboTimeZones.Items.FindByValue(StringValue).Selected = true;
            }

            //Render the Select Tag
            ControlStyle.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
            writer.RenderBeginTag(HtmlTextWriterTag.Select);

            for (int I = 0; I <= cboTimeZones.Items.Count - 1; I++)
            {
                string timeZoneValue = cboTimeZones.Items[I].Value;
                string timeZoneName = cboTimeZones.Items[I].Text;
                bool isSelected = cboTimeZones.Items[I].Selected;

                //Add the Value Attribute
                writer.AddAttribute(HtmlTextWriterAttribute.Value, timeZoneValue);

                if (isSelected)
                {
                    //Add the Selected Attribute
                    writer.AddAttribute(HtmlTextWriterAttribute.Selected, "selected");
                }

                //Render Option Tag
                writer.RenderBeginTag(HtmlTextWriterTag.Option);
                writer.Write(timeZoneName.PadRight(100).Substring(0, 50));
                writer.RenderEndTag();
            }

            //Close Select Tag
            writer.RenderEndTag();
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:48,代码来源:DNNTimeZoneEditControl.cs

示例7: SelectDropDownItem

        /// <summary>
        /// Selects the drop down item.
        /// </summary>
        /// <param name="dropdownListControl">The dropdown list control.</param>
        /// <param name="value">The value.</param>
        public static void SelectDropDownItem(DropDownList dropdownListControl, int value)
        {
            if (dropdownListControl == null)
            {
                throw new ArgumentNullException("Drop down control can not be null.");
            }

            dropdownListControl.ClearSelection();//clear existing selection.
            //find the value in the drop down item.
            ListItem item = dropdownListControl.Items.FindByValue(value.ToString());

            if (item == null) //if item is null return to called method.
            {
                return;
            }

            item.Selected = true;
        }
开发者ID:rag1379,项目名称:ITH.Sample.Trunk,代码行数:23,代码来源:WebUitl.cs

示例8: RenderEditMode

        /// <Summary>RenderEditMode renders the Edit mode of the control</Summary>
        /// <Param name="writer">A HtmlTextWriter.</Param>
        protected override void RenderEditMode( HtmlTextWriter writer )
        {
            //For convenience create a DropDownList to use
            DropDownList cboLocale = new DropDownList();

            //Load the List with Locales
            Localization.LoadCultureDropDownList(cboLocale, CultureDropDownTypes.NativeName, ((PageBase)Page).PageCulture.Name);

            //Select the relevant item
            if (cboLocale.Items.FindByValue(StringValue) != null)
            {
                cboLocale.ClearSelection();
                cboLocale.Items.FindByValue(StringValue).Selected = true;
            }

            //Render the Select Tag
            ControlStyle.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
            writer.RenderBeginTag(HtmlTextWriterTag.Select);

            for (int I = 0; I <= cboLocale.Items.Count - 1; I++)
            {
                string localeValue = cboLocale.Items[I].Value;
                string localeName = cboLocale.Items[I].Text;
                bool isSelected = cboLocale.Items[I].Selected;

                //Add the Value Attribute
                writer.AddAttribute(HtmlTextWriterAttribute.Value, localeValue);

                if (isSelected)
                {
                    //Add the Selected Attribute
                    writer.AddAttribute(HtmlTextWriterAttribute.Selected, "selected");
                }

                //Render Option Tag
                writer.RenderBeginTag(HtmlTextWriterTag.Option);
                writer.Write(localeName);
                writer.RenderEndTag();
            }

            //Close Select Tag
            writer.RenderEndTag();
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:46,代码来源:DNNLocaleEditControl.cs

示例9: BindEnum2DropDownList

        /// <summary>
        /// Pass in a DropDownList and typeof(YourEnum) as parameters to auto-bind a dropdownlist to an enum
        /// </summary>
        /// <param name="ddl">ddlMyDropDownList</param>
        /// <param name="enumType">typeof(MyEnum)</param>
        /// <param name="retainSelected">true/false indicating if the currently selected item should remain selected</param>
        public static void BindEnum2DropDownList(DropDownList ddl, Type enumType, bool retainSelected)
        {
            // retain the currently selected item if possible
            string currentlySelectedValue = string.Empty;
            if (retainSelected)
                currentlySelectedValue = ddl.SelectedValue;

            ddl.DataSource = GetListItemsFromEnum(enumType);
            ddl.DataTextField = "Text";
            ddl.DataValueField = "Value";
            ddl.DataBind();

            // in the event that there was a selected item, keep it.
            if (currentlySelectedValue != string.Empty && retainSelected == true)
            {
                ddl.ClearSelection();
                ddl.Items.FindByText(currentlySelectedValue).Selected = true;
            }
        }
开发者ID:GramozKrasniqi,项目名称:HRMS,代码行数:25,代码来源:GUIHelper.cs

示例10: RenderViewMode

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// RenderViewMode renders the View (readonly) mode of the control
        /// </summary>
        /// <param name="writer">A HtmlTextWriter.</param>
        /// <history>
        ///     [cnurse]	05/02/2006	created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void RenderViewMode(HtmlTextWriter writer)
        {
            PortalSettings _portalSettings = Globals.GetPortalSettings();

            //For convenience create a DropDownList to use
            var cboTimeZones = new DropDownList();

            //Load the List with Time Zones
            Localization.LoadTimeZoneDropDownList(cboTimeZones, ((PageBase) Page).PageCulture.Name, Convert.ToString(_portalSettings.TimeZoneOffset));

            //Select the relevant item
            if (cboTimeZones.Items.FindByValue(StringValue) != null)
            {
                cboTimeZones.ClearSelection();
                cboTimeZones.Items.FindByValue(StringValue).Selected = true;
            }
            ControlStyle.AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            writer.Write(cboTimeZones.SelectedItem.Text);
            writer.RenderEndTag();
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:30,代码来源:DNNTimeZoneEditControl.cs

示例11: BindDropDownList

 /// <summary>
 /// Binds the drop down list.
 /// </summary>
 /// <param name="dropDown">The drop down.</param>
 /// <param name="value">The value.</param>
 private void BindDropDownList(DropDownList dropDown, string value)
 {
     for (int intIndex = 0; intIndex < dropDown.Items.Count; intIndex++)
     {
         if (string.Equals(dropDown.Items[intIndex].Text, value))
         {
             dropDown.ClearSelection();
             dropDown.Items[intIndex].Selected = true;
         }
     }
 }
开发者ID:vijaymca,项目名称:Dotnet,代码行数:16,代码来源:AddChapter.ascx.cs

示例12: SetValue

 public static void SetValue(string boField, bool boFieldIsNull, DropDownList dropDownList)
 {
     dropDownList.ClearSelection();
     if (boFieldIsNull)
     {
         return;
     }
     else
     {
         ListItem li = dropDownList.Items.FindByValue(boField);
         if (!(li == null))
         {
             li.Selected = true;
         }
     }
 }
开发者ID:nicholaswilliambrown,项目名称:ProfilesRNS_ORCID,代码行数:16,代码来源:UICommon.cs

示例13: BindDropDownList

 /// <summary>
 /// Binds the drop down list.
 /// </summary>
 /// <param name="dropDown">The drop down.</param>
 /// <param name="value">The value.</param>
 private void BindDropDownList(DropDownList dropDown, string value)
 {
     if (dropDown != null)
     {
         if (dropDown.Items.FindByText(value) != null)
         {
             dropDown.ClearSelection();
             dropDown.Items.FindByText(value).Selected = true;
         }
     }
 }
开发者ID:vijaymca,项目名称:Dotnet,代码行数:16,代码来源:MasterPages.ascx.cs

示例14: SetSelectedValue

 public static void SetSelectedValue(DropDownList ComboBox, string SelectedValue)
 {
     ListItem SelectedItem = ComboBox.Items.FindByValue(SelectedValue);
       if (SelectedItem != null)
       {
     ComboBox.ClearSelection();
     SelectedItem.Selected = true;
     ComboBox.Enabled = false;
       }
 }
开发者ID:royriojas,项目名称:Clave-Projects,代码行数:10,代码来源:Utilidades.cs

示例15: SetPrivacy

 private void SetPrivacy(DropDownList ddl, string privacyLevel)
 {
     ddl.ClearSelection();
     ListItem li = ddl.Items.FindByValue(privacyLevel);
     if (!(li == null))
     {
         li.Selected = true;
     }
 }
开发者ID:nicholaswilliambrown,项目名称:ProfilesRNS_ORCID,代码行数:9,代码来源:CreateMyORCID.ascx.cs


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