本文整理匯總了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();
}
}