we can bind the data to a calender control using DayRender Event
VB.Net code
VB.Net code
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
Dim nextDate As DateTime
Dim hl As HyperLink
Dim TblCell As TableCell = CType(e, DayRenderEventArgs).Cell
TblCell.Height = CType(88, Web.UI.WebControls.Unit)
TblCell.Width = CType(200, Web.UI.WebControls.Unit)
Try
If Not CType(Session("dsEvents"), DataSet) Is Nothing Then
For Each dr As DataRow In CType(Session("dsEvents"), DataSet).Tables(0).Rows
nextDate = CType(dr("VisitationDate"), DateTime)
If Not e.Day.IsOtherMonth Then
If nextDate = e.Day.Date Then
hl = New HyperLink
If CType(dr("Branch"), String) <> "" Then
hl.Text = "
" & CType(dr("Branch"), String)
" & CType(dr("Branch"), String)
Else
hl.Text = "
" & CType(dr("Others"), String)
" & CType(dr("Others"), String)
End If
hl.NavigateUrl = "ViewDetails.aspx?ID=" & CType(dr("Id"), String)
hl.ToolTip = "Click for details."
hl.Font.Bold = False
hl.ForeColor = System.Drawing.ColorTranslator.FromHtml("#24618E")
e.Cell.BackColor = Color.Azure
e.Cell.Controls.Add(hl)
e.Cell.Wrap = True
End If
End If
Next
End If
e.Day.IsSelectable = False
Catch ex As Exception
Response.Write(ex.ToString())
End Try
End Sub
No comments:
Post a Comment