title: How to highlight specific days in a calendar control ASP.net?
body: <p>I'm trying to create a calendar that highlights dates in which an Activity takes place in the hall selected in <code>DropDownList1</code>.</p>
  
  <pre><code>public partial class Calendar : System.Web.UI.Page
  {
      IQueryable&lt;Activity&gt; activities;
  
      protected void Page_Init(object sender, EventArgs e)
      {
          int idHall;
          bool b = Int32.TryParse(DropDownList1.SelectedValue, out idHall);
          if (!b)
          {
              idHall = 2;
          }
  
          ModelDatabase db = new ModelDatabase();
  
          activities = from a in db.Activities
                       join s in db.Halls on a.hall_id_hall equals s.id_hall
                       where s.i[d_hall == idHall
                       select a;][1]
      }
  
      protected void Page_Load(object sender, EventArgs e)
      {
  
  
      }
  
      protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
      {
          foreach (Activity a in activities) {
              DateTime calendarDay = e.Day.Date;
              DateTime activityStart= a.start ?? default(DateTime);
              DateTime activityEnd = a.end ?? default(DateTime);
              if (DateTime.Compare(activityStart, calendarDay) &gt; 0 &amp;&amp; 
                  DateTime.Compare(activityEnd, calendarDay.AddDays(1)) &lt; 0)
              {
                  e.Cell.BackColor = Color.Yellow;
                  break;
              }
          }
      }
  
      protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
      {
          int idSalon = Int32.Parse(DropDownList1.SelectedValue);
  
          ModelDatabase db = new ModelDatabase();
  
          activities = from a in db.Activities
                       join h in db.Halls on a.hall_id_hall equals h.id_hall
                       where h.id_hall == idHall
                       select a;
      }
  </code></pre>