Quantcast
Viewing all articles
Browse latest Browse all 5678

Need help on the dates of the calendar!

Hi guys, I want to make a calendar with the text leave under the date when the user has choosen the date. It is working. However,for example today is 24-9-13, the user has already chosen the date thus the date 24 will have the word leave below. This is correct. However, when I change the calendar to the next month, the date 24 also has the word leave which is wrong. How do I solve this?

This is my code : 

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);
MySqlDataReader dr = cmdUser.ExecuteReader();


//using a while loop to read data from the reader
while (dr.Read())
{
DateTime dt = Convert.ToDateTime(dr["StartDate"].ToString());
if (e.Day.Date.Day == dt.Day)
{
e.Cell.Controls.Add(new LiteralControl("<br />Leave"));
}
}
dr.Close();

conn.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
Panel1.Visible = false;
Calendar1.DayRender += new DayRenderEventHandler(this.DayRender);
}

How do I solve this? Thank you!


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>