本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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"));
}
示例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();
}
示例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();
}
示例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"));
}
示例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"));
}
}
示例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();
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
示例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();
}
}