asp.net 下拉列表中的system.data.common. datarecord internal

ehxuflar  于 2023-11-20  发布在  .NET
关注(0)|答案(1)|浏览(104)


编译后我得到一个错误
system.data.common.datarecordinternal在datalist视图中
它必须获取数据库中的数据。

Dim connectionString As String = "Data Source=11.123.123.32;Initial Catalog=RESERVATION_SYSTEM;User Id=**;Password=***"

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Me.IsPostBack Then
                Using con As SqlConnection = New SqlConnection(connectionString)
                    Dim cmd As SqlCommand = New SqlCommand("Select [Room] FROM [RESERVATION_SYSTEM].[dbo].[LMO_RESERVATION_SYSTEM_ROOM]", con)
                    con.Open()
                    Dim rdr As SqlDataReader = cmd.ExecuteReader()
                    roomType.DataSource = rdr
                    roomType.DataBind()
                    roomType.DataTextField = "RESERVATION_SYSTEM"
                End Using
                roomType.Items.Insert(0, New ListItem("--Select Room --"))
            End If

字符串

qcuzuvrc

qcuzuvrc1#

This link帮助解决了我的问题。在databind之前,你需要包括你将在表中选择的列。

roomType.DataTextField = "ROOM"
roomType.DataValueField = "ROOM"

字符串

相关问题