请各位.NET大侠帮忙.关于dropdownlist的绑定问题
氪州刺史 2010-11-12 08:47:56 [size=18px] protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=wmx3ng;Initial Catalog=Storage_Management;uid=sa;pwd=;";
SqlCommand cmd = conn.CreateCommand();
if (DropDownList1.SelectedItem.Value.ToString() == "admin")
cmd.CommandText = "select * from admin";
else
cmd.CommandText = "select * from client";
conn.Open();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
DropDownList2.DataSource = ds.Tables[0].DefaultView;
DropDownList2.DataBind();
conn.Close();
}[/size]
但出现的结果是:dropdownlist2的文本框中内容显示的是:System.Data.RowView .并且这种代码的个数和数据库中的记录个数相同.
请道上的朋友帮忙解决.