首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

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

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

热点排行