datalistview中的system.data.common.datarecordinternal
它必须获取数据库中的数据。
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
答案 0 :(得分:0)
我解决了我的问题。
根据我的研究,此链接1来解决我的问题。 因此,在数据绑定之前,您需要包含要在表格中选择的列。
roomType.DataTextField = "ROOM"
roomType.DataValueField = "ROOM"