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


C# DropDownList类代码示例

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


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

示例1: BindIndustry

 public static void BindIndustry(DropDownList industryDropDownList)
 {
     industryDropDownList.DataValueField = "CategoryID";
     industryDropDownList.DataTextField = "CategoryName";
     industryDropDownList.DataSource = BindIndusty(HttpContext.Current.Session["LCID"].ToString());
     industryDropDownList.DataBind();
 }
开发者ID:haithemaraissia,项目名称:Export,代码行数:7,代码来源:Utility.cs

示例2: cargar_combo

 private void cargar_combo(DropDownList combo,String textField, String valueField)
 {
     combo.DataTextField = textField;
     combo.DataValueField = valueField;
     combo.DataBind();
     combo.SelectedIndex = 0;
 }
开发者ID:J3l1z4,项目名称:PasantiasSEU,代码行数:7,代码来源:alumno.aspx.cs

示例3: InitListLoaiXe

 public static void InitListLoaiXe(DropDownList ComboboxName)
 {
     string sql = string.Format(@"SELECT * FROM {0} tt
                  ORDER BY tt.{1}", LOAI_XE.sTableName, LOAI_XE.cl_LOAI_XE_ID);
     DataTable dt = SQLConnectWeb.GetTable(sql, LOAI_XE.sTableName);
     InitDropDownList(ComboboxName, dt, LOAI_XE.cl_LOAI_XE_ID, LOAI_XE.cl_TEN_LOAI);
 }
开发者ID:khanhdtn,项目名称:web-minhtam,代码行数:7,代码来源:HelpControls.cs

示例4: fillUnidades

    private void fillUnidades(DropDownList combo, int c)
    {
        combo.Enabled = false;
        combo.Items.Clear();
        combo.AppendDataBoundItems = true;
        combo.DataSource = psvm.getAllUnidades();
        combo.DataValueField = "UNI_COD";
        combo.DataTextField = "UNI_NOM";
        combo.DataBind();
        if (combo.Items.Count > 0)
        {
            combo.Enabled = true;

            cargo_comboUnidad_SelectedIndexChanged(combo, null);
        }
        else
        {
            combo.Enabled = false;

            combo.Items.Add(new ListItem("--Ninguno--", ""));
            cargo_comboArea.Enabled = false;
            cargo_comboArea.Items.Clear();
            cargo_comboArea.AppendDataBoundItems = true;
            cargo_comboArea.Items.Add(new ListItem("--Ninguno--", ""));
            cargo_comboArea.DataBind();

        }
    }
开发者ID:dacopan,项目名称:tathy-scpm,代码行数:28,代码来源:searchCargo.aspx.cs

示例5: InicializaCombo

 public static void InicializaCombo(DropDownList ddl)
 {
     ddl.Items.Clear();
     ddl.DataValueField = "ID";
     ddl.DataTextField = "Nombre";
     ddl.Items.Add(new ListItem("Selecciona una opción:", "-1"));
 }
开发者ID:amoras5,项目名称:cb_reinscripcion,代码行数:7,代码来源:Utils.cs

示例6: AddStaticData

 public static void AddStaticData(DropDownList ddlStatus, int nLanguageID)
 {
     switch (nLanguageID)
     {
         case 1:
             ListItem all_v = new ListItem("--- Tất cả ---", "-1", true);
             all_v.Selected = true;
             ddlStatus.Items.Add(all_v);
             ListItem active_v = new ListItem("Hoạt động", "1", true);
             ddlStatus.Items.Add(active_v);
             ListItem inactive_v = new ListItem("Không hoạt động", "0", true);
             ddlStatus.Items.Add(inactive_v);
             break;
         case 2:
             ListItem all_e = new ListItem("--- All ---", "-1", true);
             all_e.Selected = true;
             ddlStatus.Items.Add(all_e);
             ListItem active_e = new ListItem("Active", "1", true);
             ddlStatus.Items.Add(active_e);
             ListItem inactive_e = new ListItem("Inactive", "0", true);
             ddlStatus.Items.Add(inactive_e);
             break;
         case 3:
             ListItem all_j = new ListItem("--- All ---", "-1", true);
             all_j.Selected = true;
             ddlStatus.Items.Add(all_j);
             ListItem active_j = new ListItem("Active", "1", true);
             ddlStatus.Items.Add(active_j);
             ListItem inactive_j = new ListItem("Inactive", "0", true);
             ddlStatus.Items.Add(inactive_j);
             break;
     }
 }
开发者ID:changtraicantinh,项目名称:atpgroup,代码行数:33,代码来源:Support.cs

示例7: Page_Init

        // 动态创建控件
        // 注意:这段代码需要每次加载页面都执行,因此不能放在 if(!IsPostBack) 逻辑判断中
        protected void Page_Init(object sender, EventArgs e)
        {
            // 创建一个 FormRow 控件并添加到 Form2
            FormRow row = new FormRow();
            row.ID = "rowUser";
            Form2.Rows.Add(row);

            TextBox tbxUser = new TextBox();
            tbxUser.ID = "tbxUserName";
            tbxUser.Text = "";
            tbxUser.Label = "用户名";
            tbxUser.ShowLabel = true;
            tbxUser.ShowRedStar = true;
            tbxUser.Required = true;
            row.Items.Add(tbxUser);

            DropDownList ddlGender = new DropDownList();
            ddlGender.ID = "ddlGender";
            ddlGender.Label = "性别(自动回发)";
            ddlGender.Items.Add("男", "0");
            ddlGender.Items.Add("女", "1");
            ddlGender.SelectedIndex = 0;
            ddlGender.AutoPostBack = true;
            ddlGender.SelectedIndexChanged += new EventHandler(ddlGender_SelectedIndexChanged);
            row.Items.Add(ddlGender);
        }
开发者ID:jinwmmail,项目名称:RDFNew,代码行数:28,代码来源:form_dynamic.aspx.cs

示例8: BindLeaderList

    /// <summary>
    /// Binds the leader list to the current user's calendar access list.
    /// Inserts the user calendar for the selected user if it does not exist. This case would occur if 
    /// the current user does not have access to the selected user's calendar.  
    /// </summary>
    /// <param name="list">The list of user calendars.</param>
    /// <param name="selectedUserId">The selected user id.</param>
    public static void BindLeaderList(DropDownList list, string selectedUserId)
    {
        if (list.Items.Count > 1) return; // already loaded
        list.Items.Clear();
        bool selectedUserInList = false;
        List<UserCalendar> userCalendar = UserCalendar.GetCurrentUserCalendarList();
        foreach (UserCalendar uc in userCalendar)
        {
            if (uc.AllowAdd.HasValue && uc.AllowAdd.Value) // == true
            {
                if (uc.UserId.ToUpper().Trim() == selectedUserId.ToUpper().Trim()) selectedUserInList = true;
                ListItem listItem = new ListItem(uc.UserName, uc.CalUser.Id.ToString());
                list.Items.Add(listItem);
            }
        }
        UserCalendar suc = UserCalendar.GetUserCalendarById(selectedUserId);
        if (suc != null)
        {
            //Verify that we have the exact right userid.  i.e. 'ADMIN    ' may be trimmed to 'ADMIN'
            selectedUserId = suc.CalUser.Id.ToString();
            if (!selectedUserInList)
            {
                ListItem newItem = new ListItem(suc.UserName, suc.CalUser.Id.ToString());
                list.Items.Add(newItem);
            }
        }

        ListItem selected = list.Items.FindByValue(selectedUserId);
        if (selected == null)
        {
            selected = new ListItem(selectedUserId, selectedUserId);
            list.Items.Add(selected);
        }
        list.SelectedIndex = list.Items.IndexOf(selected);
    }
开发者ID:ssommerfeldt,项目名称:TAC_CFX,代码行数:42,代码来源:ActivityFacade.cs

示例9: GridView2_RowUpdating

 protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     DropDownList ddlevelForMultCh = (DropDownList)(GridView2.Rows[e.RowIndex].FindControl("ddlevelForMultCh"));
     caseOfErr = (DropDownList)(GridView2.Rows[e.RowIndex].FindControl("ddForMultChoCaseOferror"));
     e.NewValues.Add("caseOfError", caseOfErr.SelectedItem.ToString());
     e.NewValues.Add("level", ddlevelForMultCh.SelectedItem.ToString());
 }
开发者ID:ksksAsa,项目名称:aepTrain1,代码行数:7,代码来源:ManageExercises.aspx.cs

示例10: Bind

 /// <summary>
 /// Metodo para llenar un DropdownList
 /// </summary>
 /// <param name="dropDownList"></param>
 /// <param name="data"></param>
 public void Bind(DropDownList dropDownList, IList data, string value, string text)
 {
     dropDownList.DataSource = data;
     dropDownList.DataValueField = value;
     dropDownList.DataTextField = text;
     dropDownList.DataBind();
 }
开发者ID:helbert959,项目名称:Sistema_Control_Pedidos_net,代码行数:12,代码来源:UIPage.cs

示例11: LocationSelectorWithOptions

        public LocationSelectorWithOptions(
            Page page,
            bool empty,
            DropDownList country,
            DropDownList state,
            DropDownList city,
            DropDownList neighborhood,
            DropDownList type,
            CheckBox picturesonly)
            :
            base(page, empty, country, state, city, neighborhood)
        {
            mType = type;
            mPicturesOnly = picturesonly;

            if (!mPage.IsPostBack)
            {
                List<TransitPlaceType> types = new List<TransitPlaceType>();
                if (InsertEmptySelection) types.Add(new TransitPlaceType());
                types.AddRange(page.SessionManager.GetCollection<TransitPlaceType>(
                    (ServiceQueryOptions)null, page.SessionManager.PlaceService.GetPlaceTypes));
                mType.DataSource = types;
                mType.DataBind();
            }
        }
开发者ID:dblock,项目名称:sncore,代码行数:25,代码来源:PlacesView.aspx.cs

示例12: SeleccionarItemCombo

 public static void SeleccionarItemCombo(ref DropDownList combo, string valor, string texto)
 {
     combo.ClearSelection();
     if ((combo.Items.FindByValue(valor) == null))
         combo.Items.Insert(0, new ListItem(texto, valor));
     combo.Items.FindByValue(valor).Selected = true;
 }
开发者ID:kenchic,项目名称:SAF,代码行数:7,代码来源:Utilidad.cs

示例13: bindDropDownList

 /// <summary>
 /// bind DropDownList control
 /// </summary>
 /// <param name="ddl">DropDownList control need to be bound</param>
 /// <param name="ds">data source</param>
 /// <param name="flag">bind style. true for binding text and value; false for binding text only.</param>
 public void bindDropDownList(DropDownList ddl, DataSet ds, bool flag)
 {
     if (ds.Tables[0].Rows.Count > 0)
     {
         DataTable dt = ds.Tables[0];
         int count = dt.Rows.Count;
         int index = 0;
         while (index < count)
         {
             if (flag)
             {
                 var li = new ListItem(dt.Rows[index][0].ToString().Trim(), dt.Rows[index][1].ToString().Trim());
                 ddl.Items.Add(li);
             }
             else
                 ddl.Items.Add(dt.Rows[index][0].ToString().Trim());
             index++;
         }
         ddl.Enabled = true;
     }
     else
     {
         if (flag)
         {
             var li = new ListItem("Not Exist", "-1");
             ddl.Items.Add(li);
         }
         else
             ddl.Items.Add("Not Exist");
         ddl.Enabled = false;
     }
 }
开发者ID:gracianani,项目名称:SINO_CRM,代码行数:38,代码来源:CommonFunction.cs

示例14: FillCustomersDDL

    public static void FillCustomersDDL(string companyName, DropDownList ddl)
    {
        SqlDataReader sqlReader;

        SqlConnection sqlConn = new SqlConnection(sConnection);
        sqlConn.Open();

        using (SqlCommand sqlComm = new SqlCommand())
        {
            sqlComm.Connection = sqlConn;
            sqlComm.CommandType = CommandType.StoredProcedure;
            sqlComm.CommandText = "GetCustomers";

            SqlParameter sqlParam = new SqlParameter("@filter", SqlDbType.VarChar, 25);

            if (companyName != null || companyName != "")
                sqlParam.Value = companyName;
            else
                sqlParam.Value = "";

            sqlParam.Direction = ParameterDirection.Input;

            sqlComm.Parameters.Add(sqlParam);

            sqlReader = sqlComm.ExecuteReader(CommandBehavior.CloseConnection);
        }

        ddl.DataSource = sqlReader;
        ddl.DataTextField = "Company Name";
        ddl.DataValueField = "Customer ID";

        ddl.Items.Clear();
        ddl.DataBind();
        ddl.Items.Insert(0, new ListItem(String.Format("Select a Customer from [{0}]", ddl.Items.Count), "-1"));
    }
开发者ID:kbridgeman1,项目名称:CMPE2300,代码行数:35,代码来源:NorthwindAccess.cs

示例15: ddlBillingAdrs_SelectedIndexChanged

 protected void ddlBillingAdrs_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     //For Billing Adrs DDL
     DropDownList billingAddressDropDownList = new DropDownList();
     billingAddressDropDownList = (DropDownList)dvCompany.FindControl("ddlBillingAdrs");
     if (billingAddressDropDownList != null)
     {
         if (billingAddressDropDownList.SelectedValue == "1")
         {
             //Find existing Address Info
             (dvCompany.FindControl("txtBillingAddress") as TextBox).Text = (dvCompany.FindControl("txtAddress") as TextBox).Text;
             (dvCompany.FindControl("txtBillingCity") as TextBox).Text = (dvCompany.FindControl("txtCity") as TextBox).Text;
             (dvCompany.FindControl("txtBillingState") as TextBox).Text = (dvCompany.FindControl("txtState") as TextBox).Text;
             (dvCompany.FindControl("txtBillingZip") as TextBox).Text = (dvCompany.FindControl("txtZip") as TextBox).Text;
             (dvCompany.FindControl("txtBillingCountry") as TextBox).Text = (dvCompany.FindControl("txtCountry") as TextBox).Text;
             //Also make them readonly true
             (dvCompany.FindControl("txtBillingAddress") as TextBox).Enabled = false;
             (dvCompany.FindControl("txtBillingCity") as TextBox).Enabled = false;
             (dvCompany.FindControl("txtBillingState") as TextBox).Enabled = false;
             (dvCompany.FindControl("txtBillingZip") as TextBox).Enabled = false;
             (dvCompany.FindControl("txtBillingCountry") as TextBox).Enabled = false;
         }
         else
         {
             //Also make them readonly false
             (dvCompany.FindControl("txtBillingAddress") as TextBox).Enabled = true;
             (dvCompany.FindControl("txtBillingCity") as TextBox).Enabled = true;
             (dvCompany.FindControl("txtBillingState") as TextBox).Enabled = true;
             (dvCompany.FindControl("txtBillingZip") as TextBox).Enabled = true;
             (dvCompany.FindControl("txtBillingCountry") as TextBox).Enabled = true;
         }
     }
 }
开发者ID:jigshGitHub,项目名称:SandlerTrainingDevelopment,代码行数:33,代码来源:Add.aspx.cs


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