現在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>
私が行ったことで更新されましたが、それでも表示されません助けてくれてありがとう