<asp:Calendar id='Calendar1' OnDayRender ='CalDayRender' runat='server'></asp:Calendar>
Dim ds As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
’Put user code to initialize the page here
’Fill the DataSet
End Sub
Protected Sub CalDayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
Dim strName As New StringBuilder
strName.Append('
')
Dim theDay As DateTime = e.Day.Date
Dim sql As String = 'hiredate=’' + DateTime.Parse(theDay.ToString('d')) + '’ '
Dim dr As DataRow() = ds.Tables(0).Select(sql)
Dim drRow As DataRow
For Each drRow In dr
strName.Append('’<a href=empdetails.aspx?id=' + drRow('Employeeid').ToString() + '>' + drRow('FirstName').ToString() + ' ' + drRow('LastName').ToString() + '</a><br>’')
e.Cell.BackColor = Color.Teal
e.Cell.ForeColor = Color.Wheat
Next drRow
strName.Append('')
e.Cell.Controls.Add(New LiteralControl(strName.ToString()))
End Sub ’CalDayRender
C#
DataSet ds ;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
//Populate the DataSet
}
protected void CalDayRender(object sender, DayRenderEventArgs e)
{
StringBuilder strName = new StringBuilder();
strName.Append('
');
DateTime theDay = e.Day.Date;
string sql ='hiredate=’' + DateTime.Parse ( theDay.ToString('d')) + '’ ';
DataRow [] dr = ds.Tables[0].Select(sql);
foreach(DataRow drRow in dr)
{
strName.Append('’<a href=empdetails.aspx?id=' + drRow('Employeeid').ToString() + '>' + drRow('FirstName').ToString() + ' ' + drRow('LastName').ToString() + '</a><br>’')
e.Cell.BackColor = Color.Teal;
e.Cell.ForeColor = Color.Wheat;
}
strName.Append('');
e.Cell.Controls.Add(new LiteralControl(strName.ToString()));
}
Permalink