Search This Blog

Friday, November 30, 2012

Calendar show only current month date in c#




Calendar show only current month date.
//***********************************day render create cell load time**********
 protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
 if (dr.Read())
                {
                    int i;
                    for (i = 1; i <= 31; i++)
                    {
                        if (e.Day.Date.Day == i)
                        {
                            if (dr["D" + i].ToString() == "1")
                            {
                                e.Cell.BackColor = Color.Green;

                            }
                            else if (dr["D" + i].ToString() == "0")
                            {
                                e.Cell.BackColor = Color.Red;
                            }
                            else if (dr["D" + i].ToString() == "2")
                            {
                                e.Cell.BackColor = Color.Yellow;
                            }
                            else
                            {
                                e.Cell.BackColor = Color.White;
                          }
                      }
                  }
   }
            }
            else
  { 
e.Cell.Text = ""
}

No comments :