本文整理汇总了C#中DropDownList.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# DropDownList.DataBind方法的具体用法?C# DropDownList.DataBind怎么用?C# DropDownList.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DropDownList
的用法示例。
在下文中一共展示了DropDownList.DataBind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bind
/// <summary>
/// Metodo para llenar un DropdownList
/// </summary>
/// <param name="dropDownList"></param>
/// <param name="data"></param>
public void Bind(DropDownList dropDownList, IList data, string value, string text)
{
dropDownList.DataSource = data;
dropDownList.DataValueField = value;
dropDownList.DataTextField = text;
dropDownList.DataBind();
}
示例2: cargar_combo
private void cargar_combo(DropDownList combo,String textField, String valueField)
{
combo.DataTextField = textField;
combo.DataValueField = valueField;
combo.DataBind();
combo.SelectedIndex = 0;
}
示例3: BindDDL
/// <summary>
/// 绑定下拉框 \
/// eg: string strSql = "select * from myTableName ";
/// MyHelper.BindDDL(ddl_ClassBelong, strSql, "classname", "idx", null);
/// </summary>
/// <param name="myDDL">DropDownList对象</param>
/// <param name="strSql">strSql语句</param>
/// <param name="textField">textField</param>
/// <param name="valueField">valueField</param>
/// <param name="isSelected">isSelected 如果 null,将显示"请选择"</param>
public static void BindDDL(DropDownList myDDL, string strSql, string textField, string valueField, string SelectedValue)
{
//string strSql = "select * from [class] where isshow = 'YES' order by classname ";
DataSet ds = SqlHelper.ExecuteDataset(strSql);
myDDL.DataSource = ds.Tables[0];
myDDL.DataTextField = textField;
myDDL.DataValueField = valueField;
myDDL.DataBind();
if (string.IsNullOrEmpty(SelectedValue))
{
myDDL.Items.Insert(0, "请选择");
}
else
{
for (int i = 0; i < myDDL.Items.Count; i++)
{
if (myDDL.Items[i].Text == SelectedValue)
{
myDDL.Items[i].Selected = true;
break;
}
}
}
}
示例4: BindIndustry
public static void BindIndustry(DropDownList industryDropDownList)
{
industryDropDownList.DataValueField = "CategoryID";
industryDropDownList.DataTextField = "CategoryName";
industryDropDownList.DataSource = BindIndusty(HttpContext.Current.Session["LCID"].ToString());
industryDropDownList.DataBind();
}
示例5: LlenarDdlNS
public static void LlenarDdlNS(DropDownList DdlTemp, DataTable dtConsulta, string texto, string valor)
{
DdlTemp.DataSource = dtConsulta;
DdlTemp.DataTextField = texto;
DdlTemp.DataValueField = valor;
DdlTemp.DataBind();
}
示例6: fillUnidades
private void fillUnidades(DropDownList combo, int c)
{
combo.Enabled = false;
combo.Items.Clear();
combo.AppendDataBoundItems = true;
combo.DataSource = psvm.getAllUnidades();
combo.DataValueField = "UNI_COD";
combo.DataTextField = "UNI_NOM";
combo.DataBind();
if (combo.Items.Count > 0)
{
combo.Enabled = true;
cargo_comboUnidad_SelectedIndexChanged(combo, null);
}
else
{
combo.Enabled = false;
combo.Items.Add(new ListItem("--Ninguno--", ""));
cargo_comboArea.Enabled = false;
cargo_comboArea.Items.Clear();
cargo_comboArea.AppendDataBoundItems = true;
cargo_comboArea.Items.Add(new ListItem("--Ninguno--", ""));
cargo_comboArea.DataBind();
}
}
示例7: BindDropDownList
/// <summary>
/// ��DropDownList�ؼ�����ʾ����,DropDownList�ؼ�Value,Textֵ���ֱ���ڵ���str_Value,str_Textֵ
/// </summary>
/// <param name="str_Value">��DropDownList�ؼ�Valueֵ���Ӧ���ݿ���ֶ���</param>
/// <param name="str_Text">��DropDownList�ؼ�Textֵ���Ӧ���ݿ���ֶ���</param>
/// <param name="ds">Select-SQL����ȡ������Դ</param>
/// <param name="myDropDownList">DropDownList�ؼ�idֵ</param>
public static void BindDropDownList(string str_Text, string str_Value, DataSet ds, DropDownList myDropDownList)
{
myDropDownList.DataSource = ds.Tables[0].DefaultView;
myDropDownList.DataValueField = str_Value;
myDropDownList.DataTextField = str_Text;
myDropDownList.DataBind();
}
示例8: BindAdminRegionsDropDown
public static void BindAdminRegionsDropDown(String empNo, Roles role, ICacheStorage adapter, DropDownList d)
{
d.DataSource = BllAdmin.GetRegionsByRights(empNo, role, adapter);
d.DataTextField = "Value";
d.DataValueField = "Key";
d.DataBind();
}
示例9: BindColumns
void BindColumns(DropDownList combo)
{
//combo.DataSource = Page.ReportManager.RetrieveColumnsSchema(Page.Settings.Report.ReportTablesSchemaId);
combo.DataSource = Page.Settings.Columns;
combo.DataBind();
combo.Items.Insert(0, new ListItem("- - - - - - - - - - - - - -", ""));
}
示例10: Bind
public static void Bind(DropDownList ddl)
{
DataTable dt = DataAccessFactory.GetDataAccess().SelectDataTable("select * from table_roles ", "tempdb");
ddl.DataSource = dt;
ddl.DataTextField = "c_name";
ddl.DataValueField = "id";
ddl.DataBind();
}
示例11: CargaComboSeleccione
public static void CargaComboSeleccione(DropDownList combo, DataTable dt, string valor, string texto)
{
combo.DataSource = dt;
combo.DataValueField = valor;
combo.DataTextField = texto;
combo.DataBind();
combo.Items.Insert(0, new ListItem("--SELECCIONE--", "0"));
}
示例12: BindNick
public static void BindNick(DropDownList ddl, string type)
{
DataTable dt = DataAccessFactory.GetDataAccess().SelectDataTable("select * from table_departments where c_deptype='" + type + "'", "tempdb");
ddl.DataSource = dt;
ddl.DataTextField = "c_depnickname";
ddl.DataValueField = "c_depcode";
ddl.DataBind();
}
示例13: BindLookupDropDown
public static void BindLookupDropDown(DropDownList ddl, SqlDataReader dataSource, string dataTextField, string dataValueField)
{
ddl.DataSource = dataSource;
ddl.DataTextField = dataTextField;
ddl.DataValueField = dataValueField;
ddl.DataBind();
ddl.Items.Insert(0, "");
}
示例14: BindDropDownList
public static void BindDropDownList(string typename,DropDownList ddl)
{
DataTable dt = DataAccessFactory.GetDataAccess().SelectDataTable("select * from table_dicts where c_typename ='" + typename + "'", "tempdb");
ddl.DataSource = dt;
ddl.DataTextField = "c_dict_text";
ddl.DataValueField = "c_dict_value";
ddl.DataBind();
}
示例15: Bind2
public static void Bind2(DropDownList ddl)
{
DataTable dt = DataAccessFactory.GetDataAccess().SelectDataTable("select * from table_departments ", "tempdb");
ddl.DataSource = dt;
ddl.DataTextField = "c_depfullname";
ddl.DataValueField = "c_depcode";
ddl.DataBind();
}