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


C# DropDownList.DataBind方法代码示例

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


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

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Trace.Write("starting Page Load");
                if (Session["TableDataSet"] != null)
                {
                    DataSet tds = Session["TableDataSet"] as DataSet;
                    Trace.Write(tds.ToString());
                    var tablenames = GetTablenames(tds.Tables);
                    sheetCombo.DataSource = tablenames;
                    sheetCombo.DataBind();
                    GridView1.DataSource = tds.Tables[sheetCombo.SelectedIndex];
                    GridView1.DataBind();
                    //columnCombo.DataSource = tds.Tables[sheetCombo.SelectedIndex].Columns;
                    //columnCombo.DataBind();
                    //Get the list of columns to be assigned from DB

                    foreach (DataColumn columnName in tds.Tables[sheetCombo.SelectedIndex].Columns)
                    {
                        Label myLabel = new Label();
                        myLabel.Text = columnName.ToString();
                        myLabel.ID = columnName.ToString() +"label";
                        myLabel.Width = 120;
                        myLabel.Height = 28;
                        columnPanel.Controls.Add(myLabel);

                        DropDownList myDropDownList = new DropDownList();
                        myDropDownList.ID = columnName.ToString() + "combo";

                        //Remove this once table lookup in place.
                        myDropDownList.DataSource = tds.Tables[sheetCombo.SelectedIndex].Columns;
                        myDropDownList.DataBind();

                        //need to load data to control.  Following code is for proof of concept.

                        Trace.Warn("starting DB read");

                        myDropDownList.DataSource = dsColumn;
                        myDropDownList.Height = 28;
                        myDropDownList.DataValueField = "COLUMNCONFIG_IDX";
                        myDropDownList.DataTextField = "COLUMN_NAME";
                        myDropDownList.DataBind();

                        columnPanel.Controls.Add(myDropDownList);
                        //columnPanel.Controls.Add(new LiteralControl("<br/>"));
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.Warn("error caught.  " + ex.Message);
                //catch error code
            }
        }
开发者ID:OTIE-Zimmer,项目名称:Open-Waters,代码行数:55,代码来源:WQXConfigurations.aspx.cs

示例2: BindDropDownDataSource

 /// <summary>
 /// Set the selected value of a drop down.
 /// </summary>
 /// <param name="dropDownList"></param>
 /// <param name="data"></param>
 public static void BindDropDownDataSource(DropDownList dropDownList, ICollection data)
 {
     try
     {
         dropDownList.DataSource = data;
         dropDownList.DataBind();
     }
     catch (ArgumentOutOfRangeException)
     {
         dropDownList.Items.Clear();
         dropDownList.SelectedValue = null;
         dropDownList.DataSource = data;
         dropDownList.DataBind();
     }
 }
开发者ID:Confirmit,项目名称:Portal,代码行数:20,代码来源:DataBinder.cs

示例3: fillDropdownlistWithDT

 public void fillDropdownlistWithDT(DropDownList ddl, DataTable dt, String id, String title)
 {
     ddl.DataSource = dt;
     ddl.DataValueField = id;
     ddl.DataTextField = title;
     ddl.DataBind();
 }
开发者ID:rajatpatel92,项目名称:ContentManagementSystem,代码行数:7,代码来源:Functions.cs

示例4: BindDropDownList

 /// <summary>
 /// 绑定一个DropDownList
 /// </summary>
 /// <param name="ddl">DropDownList实例</param>
 /// <param name="ddlText">DropDownList显示文本</param>
 /// <param name="ddlValue">DropDownList值</param>
 /// <param name="className">类名称</param>
 /// <param name="methodName">要调用的方法</param>
 /// <param name="parameterValue">参数值</param>
 public static void BindDropDownList(DropDownList ddl, string ddlText, string ddlValue, object className, string methodName, string parameterValue)
 {
     ddl.DataSource = CallMethod(className, methodName, parameterValue);
     ddl.DataTextField = ddlText;
     ddl.DataValueField = ddlValue;
     ddl.DataBind();
 }
开发者ID:ErekTan,项目名称:HLedo,代码行数:16,代码来源:Common.cs

示例5: AddEditor

		protected override Control AddEditor(Control container)
		{
			IEnumerable<ProductBrief> productBriefs;
			try
			{
                ShopperApiClientHelperForN2Admin.AssureLimitedAuthentication(false);
                productBriefs = Context.Current.Container.Resolve<ICatalogApi>().GetProductBriefsAsync().Result;
			}
			catch
			{   // TODO - better error handling, e.g. show an input box 
                productBriefs = new ProductBrief[0];
			}

			// here we create the editor control and add it to the page
			var list = new DropDownList
						   {
							   ID = Name,
							   DataTextField = "IdAndName",
							   DataValueField = "Id",
                               DataSource = productBriefs
						   };
			list.DataBind();
			container.Controls.Add(list);
			return list;
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:25,代码来源:EditableProductAttribute.cs

示例6: BindDropdownlist

 public void BindDropdownlist(DropDownList dropdownlist, IEnumerable dataSource, string textField, string valueField)
 {
     dropdownlist.DataTextField = "TextField";
     dropdownlist.DataValueField = "ValueField";
     dropdownlist.DataSource = dataSource;
     dropdownlist.DataBind();
 }
开发者ID:baweiji,项目名称:DowntimeMetrics,代码行数:7,代码来源:DowntimesPageBase.cs

示例7: setDropdownList

 public void setDropdownList(DropDownList ddl, DataSet ds, string display, string value)
 {
     ddl.DataSource = ds;
     ddl.DataTextField = display;
     ddl.DataValueField = value;
     ddl.DataBind();
 }
开发者ID:axelander95,项目名称:CFT,代码行数:7,代码来源:Database.cs

示例8: SetDatasetToDropDownList

 //public void SetCheckBoxListForMemberList(List<Design> oLists, CheckBoxList oBoxList)
 //{
 //    foreach (Design oList in oLists)
 //    {
 //        ListItem oItem = new ListItem();
 //        oItem.Text = oList.ColumnName.ToString();
 //        oBoxList.Items.Add(oItem);
 //    }
 //}
 public void SetDatasetToDropDownList(DataSet oDS, DropDownList oDDL, String TextField, String IDField)
 {
     oDDL.DataSource = oDS;
     oDDL.DataTextField = TextField;
     oDDL.DataValueField = IDField;
     oDDL.DataBind();
 }
开发者ID:traveler33,项目名称:Class,代码行数:16,代码来源:DropDownListManager.cs

示例9: BindContactTitle

        public void BindContactTitle(DropDownList _ddlContactTitles)
        {
            ContactServiceClient contactService = null;
            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;

                TitleSearchCriteria titleCriteria = new TitleSearchCriteria();
                TitleSearchReturnValue titleReturnValue = contactService.TitleSearch(_logonSettings.LogonId, collectionRequest, titleCriteria);
                if (titleReturnValue.Title != null)
                {
                    _ddlContactTitles.DataSource = titleReturnValue.Title.Rows;
                    _ddlContactTitles.DataTextField = "TitleId";
                    _ddlContactTitles.DataValueField = "TitleId";
                    _ddlContactTitles.DataBind();
                }
                AddDefaultToDropDownList(_ddlContactTitles);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
开发者ID:advanced-joelloyd,项目名称:UghWebforms,代码行数:33,代码来源:CreateContact.aspx.cs

示例10: 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

示例11: LlenarCombo_Web

 public bool LlenarCombo_Web( DropDownList Generico )
 {
     if ( ! Validar() )
             return false;
         clsConexionBD objConexionBd = new clsConexionBD( strApp );
         try
         {
             objConexionBd.SQL = strSQL;
             if ( ! objConexionBd.LlenarDataSet( false ) )
             {
                 strError = objConexionBd.Error;
                 objConexionBd.CerrarCnx();
                 objConexionBd = null;
                 return false;
             }
             Generico.DataSource = objConexionBd.DataSet_Lleno.Tables[0];
             Generico.DataValueField = strCampoID;
             Generico.DataTextField = strCampoTexto;
             Generico.DataBind();
             objConexionBd.CerrarCnx();
             objConexionBd = null;
             return true;
         }
         catch (Exception ex)
         {
             strError = ex.Message;
             return false;
         }
 }
开发者ID:jdzapataduque,项目名称:Cursos-Capacitando,代码行数:29,代码来源:clsLlenarCombos.cs

示例12: 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

示例13: 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

示例14: 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

示例15: SetDataSource

 /// <summary>
 /// Utility function to set data source of a drop down control.
 /// </summary>
 /// <param name="dropDown"></param>
 /// <param name="dataSource"></param>
 public static void SetDataSource(DropDownList dropDown, IList dataSource)
 {
     dropDown.DataSource = dataSource;
     dropDown.DataTextField = "DisplayMember";
     dropDown.DataValueField = "ValueMember";
     dropDown.DataBind();
 }
开发者ID:williamesharp,项目名称:Aspose_Email_NET,代码行数:12,代码来源:WebUtil.cs


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