读书人

dropdownlist绑定不了数据,只显示Syst

发布时间: 2012-01-10 21:26:51 作者: rapoo

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

读书人网 >asp.net

热点推荐