日期:2014-05-20  浏览次数:20532 次

dropdownlist绑定不了数据,只显示System.Data.DataRowView
我把代码贴出来了,各位看一下是哪错了???

If   Not   IsPostBack   Then
                        Dim   astr   As   String
                        astr   =   "select   authername   from   picture "
                        Dim   cmd1   As   New   SqlCommand(astr,   conn)
                        conn.Open()
                        Dim   adp   As   New   SqlDataAdapter(cmd1)
                        Dim   ds   As   New   DataSet
                        adp.Fill(ds,   "picture ")
                        DropDownList1.DataSource   =   ds.Tables(0).DefaultView
                        DropDownList1.DataBind()
                        DropDownList1.DataTextField   =   "authername "
                        DropDownList1.DataValueField   =   "pid "
                        conn.Close()
                End   If

------解决方案--------------------
后databind,先指定text和value
------解决方案--------------------
astr = "select distinct authername from picture "

------解决方案--------------------
astr = "select authername from picture "

->

astr = "select distinct authername,pid from picture "

------解决方案--------------------
select distinct authername,pid from picture