Number of Days issue in Code behind Calender
<pre><code>//DaysinLastMonth gives me the Days in April
//DaysinCurrentMonth gives me the Days in May



     public void RunCalender(int startOfCalender, int DaysinLastMonth,int 
                                                                DaysInCurrentMonth)
        {
            int value = 0, startOfCalender1 = 0;
            for (int i = 0; i &lt; 6; i++)
            {
                HtmlTableRow tr = new HtmlTableRow();

                if (value == 0)
                   // StartOfCalender is the point where the Calender starts 
                   //from in the month display
                    startOfCalender1 = startOfCalender;
                else
                    startOfCalender1 = value;


                for (int j = 0; j &lt; 7; j++)
                {
                    HtmlTableCell tc = new HtmlTableCell();
                    tc.BgColor = "#FAAFBE";
                    // tc.ColSpan = 1;
                    //tc.Attributes.Add("class", "rowA");
                    HtmlAnchor a = new HtmlAnchor();
                    a.HRef = "http://localhost:51955/Calender.aspx";

                    a.InnerHtml = startOfCalender1.ToString();

                    startOfCalender1 += 1;
                    if (startOfCalender1 == DaysinLastMonth + 1)
                    {
                        startOfCalender1 = 1;
                    }
                    value = startOfCalender1;
                    // Add the control to the TableCell
                    tc.Controls.Add(a);
                    // Add the TableCell to the TableRow
                    tr.Cells.Add(tc);
                }
                // Add the TableRow to the Table
                tbl.Rows.Add(tr);
            }
        }
</code></pre>

<p><strong>The problem is that the current month i.e is May is not showing 31 days as it should. Not able to think how to solve this issue</strong></p>

<p><img src="http://i.stack.imgur.com/VAiBu.png" alt="enter image description here"></p>
