本文整理汇总了C#中System.Web.UI.WebControls.DropDownList类的典型用法代码示例。如果您正苦于以下问题:C# DropDownList类的具体用法?C# DropDownList怎么用?C# DropDownList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DropDownList类属于System.Web.UI.WebControls命名空间,在下文中一共展示了DropDownList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: BindListInternal
internal static void BindListInternal(DropDownList comboBox, object value, IEnumerable listSource, string textField, string valueField)
{
if (comboBox != null)
{
string selectedValue = !comboBox.Page.IsPostBack ? Convert.ToString(value) : comboBox.SelectedValue;
if (listSource is Dictionary<string, string>)
{
var items = listSource as Dictionary<string, string>;
foreach (var item in items)
{
comboBox.Items.Add(new ListItem(item.Key, item.Value));
}
}
else
{
comboBox.DataTextField = textField;
comboBox.DataValueField = valueField;
comboBox.DataSource = listSource;
comboBox.DataBind();
}
//Reset SelectedValue
comboBox.Select(selectedValue);
}
}
开发者ID:biganth,项目名称:Curt,代码行数:27,代码来源:DnnFormComboBoxItem.cs
示例17: CreateChildControls
protected internal override void CreateChildControls()
{
ControlCollection controls = this.Controls;
controls.Clear();
TypeConverter converter = TypeDescriptor.GetConverter(typeof(PartChromeState));
this._chromeState = new DropDownList();
this._chromeState.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeState_Normal"), converter.ConvertToString(PartChromeState.Normal)));
this._chromeState.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeState_Minimized"), converter.ConvertToString(PartChromeState.Minimized)));
controls.Add(this._chromeState);
this._zone = new DropDownList();
WebPartManager webPartManager = base.WebPartManager;
if (webPartManager != null)
{
WebPartZoneCollection zones = webPartManager.Zones;
if (zones != null)
{
foreach (WebPartZoneBase base2 in zones)
{
ListItem item = new ListItem(base2.DisplayTitle, base2.ID);
this._zone.Items.Add(item);
}
}
}
controls.Add(this._zone);
this._zoneIndex = new TextBox();
this._zoneIndex.Columns = 10;
controls.Add(this._zoneIndex);
foreach (Control control in controls)
{
control.EnableViewState = false;
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:LayoutEditorPart.cs
示例18: Estado
public Estado(DropDownList ddl)
{
ddl.Items.Clear();
ddl.Items.Add("");
ddl.Items.Add(new ListItem("Acre", "AC"));
ddl.Items.Add(new ListItem("Alagoas", "AL"));
ddl.Items.Add(new ListItem("Amapá", "AP"));
ddl.Items.Add(new ListItem("Amazonas", "AM"));
ddl.Items.Add(new ListItem("Bahia", "BA"));
ddl.Items.Add(new ListItem("Ceará", "CE"));
ddl.Items.Add(new ListItem("Distrito Federal", "DF"));
ddl.Items.Add(new ListItem("Espírito Santo", "ES"));
ddl.Items.Add(new ListItem("Goiás", "GO"));
ddl.Items.Add(new ListItem("Maranhão", "MA"));
ddl.Items.Add(new ListItem("Mato Grosso", "MT"));
ddl.Items.Add(new ListItem("Mato Grosso do Sul", "MS"));
ddl.Items.Add(new ListItem("Minas Gerais", "MG"));
ddl.Items.Add(new ListItem("Pará", "PA"));
ddl.Items.Add(new ListItem("Paraíba", "PB"));
ddl.Items.Add(new ListItem("Paraná", "PR"));
ddl.Items.Add(new ListItem("Pernambuco", "PE"));
ddl.Items.Add(new ListItem("Piauí", "PI"));
ddl.Items.Add(new ListItem("Rio de Janeiro", "RJ"));
ddl.Items.Add(new ListItem("Rio Grande do Norte", "RN"));
ddl.Items.Add(new ListItem("Rio Grando do Sul", "RS"));
ddl.Items.Add(new ListItem("Rondônia", "RO"));
ddl.Items.Add(new ListItem("Rorâima", "RR"));
ddl.Items.Add(new ListItem("Santa Catarina", "SC"));
ddl.Items.Add(new ListItem("São Paulo", "SP"));
ddl.Items.Add(new ListItem("Sergipe", "SE"));
ddl.Items.Add(new ListItem("Tocantins", "TO"));
}
开发者ID:Janailson,项目名称:loja,代码行数:32,代码来源:Estado.cs
示例19: load_data_to_cbo_bo_tinh
public static void load_data_to_cbo_bo_tinh(
eTAT_CA ip_e_tat_ca
, DropDownList ip_obj_cbo_bo_tinh)
{
US_DM_DON_VI v_us_dm_don_vi = new US_DM_DON_VI();
DS_DM_DON_VI v_ds_dm_don_vi = new DS_DM_DON_VI();
//v_us_dm_don_vi.FillDataset(v_ds_dm_don_vi, "where ID_LOAI_DON_VI = " + ID_LOAI_DON_VI.BO_TINH);
string v_str_user_name = HttpContext.Current.Session[SESSION.UserName].ToString();
v_us_dm_don_vi.FillDataset(
v_ds_dm_don_vi
, ID_LOAI_DON_VI.BO_TINH
, CONST_QLDB.ID_TAT_CA
, CONST_QLDB.ID_TAT_CA
, v_str_user_name);
ip_obj_cbo_bo_tinh.DataSource = v_ds_dm_don_vi.DM_DON_VI;
ip_obj_cbo_bo_tinh.DataTextField = DM_DON_VI.TEN_DON_VI;
ip_obj_cbo_bo_tinh.DataValueField = DM_DON_VI.ID;
ip_obj_cbo_bo_tinh.DataBind();
if (ip_e_tat_ca == eTAT_CA.YES)
{
ip_obj_cbo_bo_tinh.Items.Insert(0, new ListItem(CONST_QLDB.TAT_CA, CONST_QLDB.ID_TAT_CA.ToString()));
}
}
开发者ID:chutinhha,项目名称:bki-quan-ly-tai-san,代码行数:26,代码来源:WinFormControls.cs
示例20: BindDate
public static void BindDate(DropDownList ddlStartYear, DropDownList ddlStartMonth, DropDownList ddlEndYear, DropDownList ddlEndMonth)
{
ddlStartYear.BindYear();
ddlStartMonth.BindMonth();
ddlEndYear.BindYear();
ddlEndMonth.BindMonth();
}
开发者ID:LuoSven,项目名称:EM,代码行数:7,代码来源:TopucDate.cs
注:本文中的System.Web.UI.WebControls.DropDownList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论