This is to help developers to display the selected dates from a table to calender control using DayRender event of Calender control
Steps
1.Create a table containing following fields
2. write a stored procedure to select dates from database
corresponding to a specific user ID as follows
Please Note that here DISPLAYSCHEDULE is the procedure name
and PSSDocShed is the table Name
3.write the business layer function as follows
4.Now create a calender control in aspx page from its property window click DayRender Event and Write the following code
Here the business class is included in the namespace LID is passed as id which is retrieved by cookie value now the dates from database are displayed in Pink color.
Steps
1.Create a table containing following fields
Code:
LID varchar(50) date datetime
corresponding to a specific user ID as follows
Code:
CREATE PROCEDURE DISPLAYSCHEDULE
@LID varchar(50)
AS
select date from PSSDocShed
where LID=@LID
and PSSDocShed is the table Name
3.write the business layer function as follows
Code:
public static DataTable displayschedule(string id)
{
DbCommand cmd = GenericData.CreateCommand();
cmd.CommandText = "DISPLAYSCHEDULE";
cmd.Parameters.Add(new SqlParameter("@LID", id));
return GenericData.ExecuteReader(cmd);
}
Code:
protected void Calendar1_DayRender (objectsender,DayRenderEventArgs e)
{
string id = Request.Cookies["PSSuid"].Value;
DataTable tb = businessclass.displayschedule(id);
for (int i = 0; i < tb.Rows.Count; i++)
{
if (e.Day.Date == Convert.ToDateTime(tb.Rows[i][0]))
{
e.Cell.BackColor = System.Drawing.Color.Pink;
}
}
}