我目前正在使用VB。我想做一个日历控件,其中突出显示/选择了日期。所有这些日期都是从数据库中检索的。
我需要知道的第一件事是如何将所有日期放入数组中我需要知道的第二件事是如何突出显示数组中的所有日期。
我在互联网上做了一些研究,他们说了一些关于 selectedDates 和 selectedDates 集合和 dayrender 的内容。但坦率地说,我真的找不到任何关于此的 VB 代码。日期格式为 dd/MM/yyyy
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim connectionString As String = ConfigurationManager.ConnectionStrings("CleanOneConnectionString").ConnectionString
Dim connection As SqlConnection = New SqlConnection(connectionString)
connection.Open()
Dim sql As String = "Select schedule From OrderDetails Where schedule is not null"
Dim command As SqlCommand = New SqlCommand(sql, connection)
Dim reader As SqlDataReader = command.ExecuteReader()
If (reader.Read()) Then
If (reader.HasRows) Then
While reader.Read()
myCalendar.SelectedDates.Add(CType(reader.GetDateTime(0), Date))
End While
End If
End If
reader.Close()
connection.Close()
myCalendar.SelectedDayStyle.BackColor = System.Drawing.Color.Red
End Sub
End Class
我的日历
<asp:Calendar ID="myCalendar" runat="server" ShowGridLines="True">
</asp:Calendar>
更新了我所做的,但仍然没有显示感谢您的帮助