Sub Calendar1_Dayrender(ByVal sender As Object, ByVal e As DayRenderEventArgs) Handles Calendar1.DayRender
Dim objConn As New SqlClient.SqlConnection
Dim objCmd As New SqlClient.SqlCommand
Dim dtAdapter As New SqlClient.SqlDataAdapter
Dim ds As New DataSet
Dim strConnString, strSQL As String
strConnString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
strSQL = "SELECT * FROM Pdata"
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dtAdapter = Nothing
For Each dr As DataRow In ds.Tables(0).Rows
Dim sc As String = dr("Pno")
Dim startDate As Date
startDate = dr("PDate")
If e.Day.Date = startDate Then
e.Cell.BackColor = System.Drawing.Color.DarkGreen
e.Cell.Controls.Add(New LiteralControl(ChrW(60) & "br" & ChrW(62) & sc))
sc = ""
' Continue For
Exit For
End If
Next
End Sub
Tag : .NET, Web (ASP.NET), VS 2012 (.NET 4.x), Windows