DropDownList绑定显示数据库多个字段
2016-01-31 22:00
429 查看
正常的下拉框的绑定如下:
上面显示的text是name,如果需要显示name加上email,该如何呢
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);
}
相关文章推荐
- 4.windows和Linux下创建oracleusername表空间,表,插入数据,用户管理表等操作
- Ubuntu彻底删除mysql
- Redis的常用方法总结
- Redis 源码分析(二) 一个 rehash 也不阻塞的哈希表
- windows-安装mysql服务
- Linq to SQL 中datetime 和string转换
- redis集群
- mysql数据库——DBA
- 超时时间已到。超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大小。
- springmvc mybatis(oracle 和 mysql) HTML5 全新高大尚后台框架 bootstrap
- java中MongoDB的简单应用实例
- 第二天ci项目规划 数据库设计
- Oracle 之 TX锁
- 《MariaDB必知必会》笔记
- SQL Server 2012 导出数据及分离MDF、LDF
- Broadleaf电商系统开发(四) - 切换到mysql
- oracle 关于直方图
- oracle分析函数(1)
- mongodb按顺序取数据
- 查看在数据库中实际执行时的解析计划