为什么我不能将值绑定到下拉列表?它总是返回消息:DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Name'.
我有一个下拉列表:
<asp:DropDownList ID="Parameter_Dropdownlist" runat="server">
</asp:DropDownList>
然后在代码隐藏上:
If myCEConnection.State = ConnectionState.Closed Then
Try
myCEConnection.Open()
Catch
Return
End Try
End If
Dim reader As SqlCeDataReader
Dim myCommand As SqlCeCommand = myCEConnection.CreateCommand()
myCommand.CommandText = "SELECT Name, Code FROM Room"
reader = myCommand.ExecuteReader()
DT.Load(reader)
DDL.DataSource = DT
DDL.DataTextField = DT.Columns("Name").ColumnName.ToString()
DDL.DataValueField = DT.Columns("Code").ColumnName.ToString()
DDL.DataBind()
myCEConnection.Close()
如何将值绑定到下拉列表?请帮忙。非常感谢。