问题: 在VS中用dropdownlist控件绑定数据,浏览时却在控件里显示System.Data.DataRowView,而不是要显示的数据,代码如下:
/// <summary>
/// 绑定DropDownList
/// </summary>
private void ListBind()
{
//功能列表
DataSet ds = bllPower.GetAllList();
this.DDLPower_Id.DataSource = ds;
this.DDLPower_Id.DataBind();
this.DDLPower_Id.Items.Insert(0, "----请选择父节点----"); //这个是设置插入静态的数据
}
/// 绑定DropDownList
/// </summary>
private void ListBind()
{
//功能列表
DataSet ds = bllPower.GetAllList();
this.DDLPower_Id.DataSource = ds;
this.DDLPower_Id.DataBind();
this.DDLPower_Id.Items.Insert(0, "----请选择父节点----"); //这个是设置插入静态的数据
}
解决:在DataBind();前加上
DDLPower_Id.DataTextField = "deptName";
DDLPower_Id.DataValueField = "deptName";