当前位置: 代码迷 >> ASP.NET >> dropdownlist绑定不了数据,只显示System.Data.DataRowView解决方案
  详细解决方案

dropdownlist绑定不了数据,只显示System.Data.DataRowView解决方案

热度:4736   发布时间:2013-02-26 00:00:00.0
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
  相关解决方案