當前位置: 首頁>>代碼示例>>C#>>正文


C# ListControl.DataBind方法代碼示例

本文整理匯總了C#中System.Web.UI.WebControls.ListControl.DataBind方法的典型用法代碼示例。如果您正苦於以下問題:C# ListControl.DataBind方法的具體用法?C# ListControl.DataBind怎麽用?C# ListControl.DataBind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.UI.WebControls.ListControl的用法示例。


在下文中一共展示了ListControl.DataBind方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Bind2CheckBoxList

 // This function binds the given CheckBoxList with the given data table with respect to the data text field and the value field.
 public static void Bind2CheckBoxList(ListControl chk, DataTable dt, string textField, string valueField)
 {
     chk.DataSource = dt;
     chk.DataTextField = textField;
     chk.DataValueField = valueField;
     chk.DataBind();
 }
開發者ID:recepSungurtas,項目名稱:increment-the-app,代碼行數:8,代碼來源:UI.cs

示例2: Bind2Ddl

 public static void Bind2Ddl(ListControl ddl, DataTable dt, string textField, string valueField)
 {
     ddl.DataSource = dt;
     ddl.DataTextField = textField;
     ddl.DataValueField = valueField;
     ddl.DataBind();
 }
開發者ID:jon0638,項目名稱:simeria,代碼行數:7,代碼來源:Database.cs

示例3: Fillchk

 public static void Fillchk(ListControl control, string key, string value, object data)
 {
     control.DataSource = data;
     control.DataValueField = key;
     control.DataTextField = value;
     control.DataBind();
 }
開發者ID:Antoniotoress1992,項目名稱:asp,代碼行數:7,代碼來源:ucNewLead.ascx.cs

示例4: FillRange

 public static void FillRange(ListControl control, int min = 1, int max = 10)
 {
     control.DataSource = GetRange(min, max);
     control.DataValueField = "key";
     control.DataTextField = "value";
     control.DataBind();
 }
開發者ID:Antoniotoress1992,項目名稱:asp,代碼行數:7,代碼來源:CollectionManager.cs

示例5: Bind2RadioButtonList

 // This function binds the given RadioButtonList with the given data table with respect to the data text field and the value field.
 public static void Bind2RadioButtonList(ListControl rbl, DataTable dt, string textField, string valueField)
 {
     rbl.DataSource = dt;
     rbl.DataTextField = textField;
     rbl.DataValueField = valueField;
     rbl.DataBind();
 }
開發者ID:recepSungurtas,項目名稱:increment-the-app,代碼行數:8,代碼來源:UI.cs

示例6: BindObject

 public static void BindObject(ListControl ddl, DataTable data, string textColumn, string valueConlumn, string defaultText)
 {
     ddl.DataSource = data;
     ddl.DataTextField = textColumn;
     ddl.DataValueField = valueConlumn;
     ddl.DataBind();
     ddl.Items.Insert(0, new ListItem(defaultText, "-1"));
 }
開發者ID:jpesquibel,項目名稱:Projects,代碼行數:8,代碼來源:FormGeneratorTools.cs

示例7: BindListControl

        private static Dictionary<string, Dictionary<int, string>> _EnumList = new Dictionary<string, Dictionary<int, string>>(); //枚舉緩存池

        #endregion Fields

        #region Methods

        /// <summary>
        /// bind source for ListControl;ex:DropDown,ListBox;
        /// </summary>
        /// <param name="listControl"></param>
        /// <param name="enumType"></param>
        public static void BindListControl(ListControl listControl, Type enumType)
        {
            listControl.Items.Clear();
            listControl.DataSource = EnumToDictionary(enumType);
            listControl.DataValueField = "key";
            listControl.DataTextField = "value";
            listControl.DataBind();
        }
開發者ID:NameIsBad,項目名稱:WXFlow,代碼行數:19,代碼來源:EnumHelper.cs

示例8: BindToEnum

        public static void BindToEnum(Type enumType, ListControl lc, bool addEmpty)
        {
            Dictionary<string, string> ht = EnumToDictionary(enumType, addEmpty);

            lc.DataSource = ht.OrderBy(x => x.Key);
            lc.DataTextField = "Key";
            lc.DataValueField = "Value";
            lc.DataBind();
        }
開發者ID:DavideMontersino,項目名稱:DataHelper,代碼行數:9,代碼來源:PageMapper.cs

示例9: FillCollection

        public static void FillCollection(ListControl control, string key, string value, object data, bool isAddSelect = true)
        {
            control.DataSource = data;
            control.DataValueField = key;
            control.DataTextField = value;
            control.DataBind();

            if (isAddSelect)
                control.Items.Insert(0, new ListItem("--- Select ---", "0"));
        }
開發者ID:Antoniotoress1992,項目名稱:asp,代碼行數:10,代碼來源:CollectionManager.cs

示例10: FillList

 public static void FillList(ListControl ctrl, DataTable dataSource, string DataTextField, string DataValueField, bool UseOthersOption = true, string OthersLabel = "Select", string othersValue = "-1")
 {
     ctrl.Items.Clear();
     ctrl.DataTextField = DataTextField;
     ctrl.DataValueField = DataValueField;
     ctrl.DataSource = dataSource;
     ctrl.DataBind();
     if (UseOthersOption)
     {
         ctrl.Items.Insert(0, new ListItem(OthersLabel, "-1"));
     }
 }
開發者ID:harikk,項目名稱:aspDbLib,代碼行數:12,代碼來源:Utils.cs

示例11: ListControlsDataSourceBind

 /// <summary>
 /// 列表類型控件數據綁定。
 /// </summary>
 /// <param name="control">列表類型控件(BulletedList,CheckBoxList,DropDownList,ListBox,RadioButtonList)。</param>
 /// <param name="listControlsDataSource">數據源接口。</param>
 public void ListControlsDataSourceBind(ListControl control, IListControlsData listControlsDataSource)
 {
     if (control != null && listControlsDataSource != null)
     {
         control.DataTextField = listControlsDataSource.DataTextField;
         if (!string.IsNullOrEmpty(listControlsDataSource.DataTextFormatString))
             control.DataTextFormatString = listControlsDataSource.DataTextFormatString;
         control.DataValueField = listControlsDataSource.DataValueField;
         control.DataSource = listControlsDataSource.DataSource;
         control.DataBind();
     }
 }
開發者ID:jeasonyoung,項目名稱:csharp_ipower,代碼行數:17,代碼來源:BaseModulePageDataBind.cs

示例12: BindDictionaryToListControl

        public static void BindDictionaryToListControl(ListControl list, string categoryName)
        {
            list.DataSource = SystemDictionaryWrapper.GetDictionaryByCategoryName(categoryName);
            list.DataTextField = SystemDictionaryWrapper.PROPERTY_NAME_SYSTEMDICTIONARYVALUE;
            list.DataValueField = SystemDictionaryWrapper.PROPERTY_NAME_SYSTEMDICTIONARYKEY;
            list.DataBind();

            if (list.Items.Count > 0)
            {
                list.SelectedIndex = 0;
            }
        }
開發者ID:Ravivishnubhotla,項目名稱:basewebframework,代碼行數:12,代碼來源:SysDictionaryWrapper.cs

示例13: BindEnumToListControls

        public static void BindEnumToListControls(Type enumType, ListControl listcontrol)
        {
            string[] names = Enum.GetNames(enumType);

            listcontrol.DataSource = names.Select((key, value) =>

                                       new { key, value }).ToDictionary(x => x.key, x => x.value);

              listcontrol.DataTextField = "Key";

              listcontrol.DataValueField = "Value";

             listcontrol.DataBind();
        }
開發者ID:marianoir,項目名稱:ReportesFrontEnd,代碼行數:14,代碼來源:HelperControl.cs

示例14: SingleSelectControl

        public SingleSelectControl(SingleSelect question)
        {
            RepeatDirection direction = question.Vertical ? RepeatDirection.Vertical : RepeatDirection.Horizontal;

            switch (question.SelectionType)
            {
                case Items.SingleSelectType.DropDown:
                    lc = new DropDownList();
                    break;
                case Items.SingleSelectType.ListBox:
                    var lb = new ListBox();
                    lb.SelectionMode = ListSelectionMode.Single;
                    lc = lb;
                    break;
                case Items.SingleSelectType.RadioButtons:
                    var rbl = new RadioButtonList();
                    rbl.RepeatLayout = RepeatLayout.Flow;
                    rbl.RepeatDirection = direction;
                    lc = rbl;
                    break;
            }

            lc.CssClass = "alternatives";
            if (question.ID > 0)
                lc.ID = "q" + question.ID;
            lc.DataTextField = "Title";
            lc.DataValueField = "ID";
			lc.DataSource = question.Children.WhereAccessible();
            lc.DataBind();

            l = new Label();
            l.CssClass = "label";
            l.Text = question.Title;
            if (question.ID > 0)
                l.AssociatedControlID = lc.ID;

            Controls.Add(l);
            Controls.Add(lc);

            if (question.Required)
            {
                cv = new CustomValidator { Display = ValidatorDisplay.Dynamic, Text = "*" };
                cv.ErrorMessage = question.Title + " is required";
                cv.ServerValidate += (s, a) => a.IsValid = !string.IsNullOrEmpty(AnswerText);
                cv.ValidationGroup = "Form";
                Controls.Add(cv);
            }
        }
開發者ID:EzyWebwerkstaden,項目名稱:n2cms,代碼行數:48,代碼來源:SingleSelectControl.cs

示例15: BindDropDownList

        public static void BindDropDownList(ListControl list, string schemaName, string tableName, string valueField, string displayField)
        {
            if(list == null)
            {
                return;
            }

            using(DataTable table = MixERP.Net.BusinessLayer.Helpers.FormHelper.GetTable(schemaName, tableName))
            {
                table.Columns.Add("text_field", typeof(string), displayField);

                list.DataSource = table;
                list.DataValueField = valueField;
                list.DataTextField = "text_field";
                list.DataBind();
            }
        }
開發者ID:ravikumr070,項目名稱:mixerp,代碼行數:17,代碼來源:DropDownListHelper.cs


注:本文中的System.Web.UI.WebControls.ListControl.DataBind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。