Hi all, I want do something like highlighting all the dates that the user chose. From the starting date to the ending date.
This are my codes, how do I modify to make it highlight all the dates that the user chose?
void DayRender(Object sender, DayRenderEventArgs e)
{
string user = (string)Session["UserID"];
string connStr1 = ConfigurationManager.ConnectionStrings["chinastudydbEntities"].ConnectionString;
MySqlConnection conn = new MySqlConnection(connStr1);
conn.Open();
MySqlCommand cmdUser = new MySqlCommand("SELECT * FROM attendance where UserID = '"+user+"'", conn);
MySqlCommand cmdDate = new MySqlCommand("SELECT StartDate from attendance where UserID = '" + user + "'", conn);
MySqlDataReader dr = cmdUser.ExecuteReader();
//using a while loop to read data from the reader
while (dr.Read())
{
DateTime dt = Convert.ToDateTime(dr["StartDate"].ToString());
DateTime dtEnd = Convert.ToDateTime(dr["EndDate"].ToString());
if (e.Day.Date.Date == dt.Date)
{
e.Cell.Controls.Add(new LiteralControl("<br /><label style='color:black'>Leave</label>"));
e.Cell.BackColor = System.Drawing.Color.Red;
}
}
dr.Close();
conn.Close();
}