ASP.Net - Calendar control

The Calendar control is pretty cool. It gives you a picture of a calendar. You can also tie events to that calendar.

Initialization

1
cal.SelectedDate=Date.today

Displaying Values in the calendar

You do this one day at a time with the render event

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Private Sub cal_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles cal.DayRender
Dim str As String

' lets populate the datagrid with information on this person
str = "select sum(quantity * multiplier) " _
& "from st_wo_cost e " _
& "where ItemName='" & txtWho.Text & "' " _
& " and CostType='L' " _
& " and abs(datediff(d, work_date, cast('" & e.Day.Date.ToShortDateString & "' as datetime)))<1 " _
& "group by work_date "

Dim amt As String _
= dl_db.SQL_Calc(str, "ConnectionString")

If Not e.Day.IsOtherMonth And Not e.Day.IsWeekend Then
Else
e.Cell.BackColor = System.Drawing.Color.Linen
End If

If amt.Length > 0 Then
If CDbl(amt) > 0 Then
e.Cell.Controls.Add( _
New LiteralControl(ChrW(60) & "br" & ChrW(62) & CDbl(amt).ToString("###.#") & " hrs"))
End If
End If

End Sub