I’ve got a simple asp.net calender which highlights and enters the users name on the days they have requested a holiday. However the newest request overwrites the name of the old request rather than showing multiple names. The code as follows:
Protected Sub Calendar1_DayRender(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) _
Handles Calendar1.DayRender
Dim nextDate As DateTime
Dim StartDate As DateTime
Dim Enddate As DateTime
Dim username As String
If Not dsHolidays Is Nothing Then
For Each dr As DataRow In dsHolidays.Tables(0).Rows
StartDate = CType(dr("StartDate"), DateTime)
Enddate = CType(dr("EndDate"), DateTime)
nextDate = CType(dr("startdate"), DateTime)
username = CType(dr("username"), String)
If e.Day.Date >= StartDate And e.Day.Date <= Enddate Then
e.Cell.Text = username
e.Cell.BackColor = System.Drawing.Color.Pink
End If
Next
End If
End Sub
Any suggestions?
You are not appending the username to the cell text. To display a list of the user names, change the line e.Cell.Text = username to e.Cell.Text += username.
One alternative would be to add controls to the cell dynamically (e.g. e.Cell.Controls.Add(new LiteralControl(username));) instead of simply displaying the text.
This should get you on the right track.