正常的下拉框的绑定如下:
Hashtable hashtable = new Hashtable();
hashtable.Add("usertype", 3);
DataTable dt = this.GetTableListAll(hashtable);
this.DDL_LOGIN_NAME.DataSource = dt;
this.DDL_LOGIN_NAME.DataTextField = "name";
this.DDL_LOGIN_NAME.DataValueField = "id";
this.DDL_LOGIN_NAME.DataBind();
上面显示的text是name,如果需要显示name加上email,该如何呢
Hashtable hashtable = new Hashtable();
hashtable.Add("usertype", 3);
DataTable dt = this.GetTableListAll(hashtable);
for (int i = 0; i < dt.Rows.Count;i++ )
{
string strText = dt.Rows[i]["name"].ToString() + "|" + dt.Rows[i]["email"].ToString();
string strValue = dt.Rows[i]["id"].ToString(); ;
ListItem listItem = new ListItem
{
Text = strText,
Value = strValue
};
this.DDL_LOGIN_NAME.Items.Add(listItem);
}