当前位置: 首页>>代码示例>>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;未经允许,请勿转载。