title: Creating table header using C#
body: <p>I am trying to create table like spreadsheet using asp.net C# table to use it as timesheet
  right now I can create table numberOFDayInMonth X 4 cols. I need some help in how to add header name and text box control to table dynamically?? could someone help me ??  </p>
  
  <p>my C# code </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Globalization;
  
  namespace Compudata_ProjectManager
  {
      public partial class testPage : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  DateTimeFormatInfo info = DateTimeFormatInfo.GetInstance(null);
  
                  for (int i = 1; i &lt; 13; i++)
                  {
  
                      //Response.Write(info.GetAbbreviatedMonthName(i) + "&lt;br /&gt;");
  
                      ddl_months.Items.Add(new ListItem(info.GetMonthName(i), i.ToString()));
  
                  }
              }
          }
  
          protected void ddl_months_SelectedIndexChanged(object sender, EventArgs e)
          {
              // Remove all the current rows and cells.
              // This is not necessary if EnableViewState is set to false.
              tbl_timesheet.Controls.Clear();
              //declare datetime dt
              DateTime dt =  new DateTime();
              int orderOfMonth = Convert.ToInt32(ddl_months.SelectedValue.ToString());
              //get number of date in X month
              int noOfDays = DateTime.DaysInMonth(dt.Year, orderOfMonth);
              int numOfCols = 4;
              for (int row = 0; row &lt; noOfDays; row++)
              {
                  // Create a new TableRow object.
                  TableRow rowNew = new TableRow();
                  // Put the TableRow in the Table.
                  tbl_timesheet.Controls.Add(rowNew);
                  for (int col = 0; col &lt; numOfCols; col++)
                  {
                      // Create a new TableCell object.
                      TableCell cellNew = new TableCell();
                      cellNew.Text = "Example Cell (" + row.ToString() + ",";
                      cellNew.Text += col.ToString() + ")";
  
                      // Put the TableCell in the TableRow.
                      rowNew.Controls.Add(cellNew);
                  }
              }
  
          }
  
  
      }
  }
  </code></pre>