Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.Date.Day = 16 And e.Day.Date.Month = 4 Then
'e.Cell.Controls.Add(New LiteralControl("<div>data</div>"))
e.Cell.BorderColor = Drawing.Color.Black
e.Cell.BorderWidth = 1
e.Cell.BorderStyle = BorderStyle.Solid
e.Cell.BackColor = Drawing.Color.LightGray
End If
End Sub
Tag : .NET, Ms Access, VBScript, VS 2010 (.NET 4.x)
Imports System.Data
Imports System.Data.OleDb
Partial Class Dayrender3
Inherits System.Web.UI.Page
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim strConnString As String
Dim strSQL As String
Dim dataReader As OleDbDataReader
Dim dSet As New DataSet
Dim dAdapter As OleDbDataAdapter
Dim dsHolidays As New DataSet
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Calendar1_Dayrender(ByVal sender As Object, ByVal e As DayRenderEventArgs) Handles Calendar1.DayRender
strConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("~/App_Data/Database1.accdb") & ";Jet OLEDB:Database Password=;"
strSQL = "SELECT * FROM calendar_table ORDER BY ID ASC"
objConn = New OleDbConnection(strConnString)
'objConn.Open()
objCmd = New OleDbCommand(strSQL, objConn)
'dataReader = objCmd.ExecuteReader()
dAdapter = New OleDbDataAdapter(strSQL, strConnString)
dAdapter.Fill(dSet)
Dim startDate As DateTime
For Each dr As DataRow In dSet.Tables(0).Rows
startDate = CType(dr("startdate"), DateTime)
If e.Day.Date = startDate Then
e.Cell.BackColor = System.Drawing.Color.Pink
End If
Next
End Sub
End Class