title: GridView getting height and width of columns/rows
body: <p>I am trying to set the top gridview's column's width to the body's column width and then the left columns height to the body's coloumns height. Here is my code:</p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
      &lt;asp:Table ID="Table1" runat="server"&gt;
          &lt;asp:TableRow&gt;
              &lt;asp:TableCell&gt;
              &lt;/asp:TableCell&gt;&lt;asp:TableCell&gt;
                  &lt;asp:GridView ID="GridView2" runat="server" ShowHeader="false"&gt;
                  &lt;/asp:GridView&gt;
              &lt;/asp:TableCell&gt;&lt;/asp:TableRow&gt;
          &lt;asp:TableRow&gt;
              &lt;asp:TableCell&gt;
                  &lt;asp:GridView ID="GridView3" runat="server" ShowHeader="false"&gt;
                  &lt;/asp:GridView&gt;
              &lt;/asp:TableCell&gt;&lt;asp:TableCell&gt;
                  &lt;asp:GridView ID="GridView4" runat="server" ShowHeader="false"&gt;
                  &lt;/asp:GridView&gt;
              &lt;/asp:TableCell&gt;&lt;/asp:TableRow&gt;
      &lt;/asp:Table&gt;
  &lt;/div&gt;
  &lt;asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the code behinde:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  DataTable dt1 = new DataTable();
                  DataTable dt2 = new DataTable();
                  DataTable dt3 = new DataTable();
  
                  DataRow row;
  
                  dt1.Columns.Add(new DataColumn("Description", Type.GetType("System.String")));
                  dt1.Columns.Add(new DataColumn("ROXORZZOZO!!", Type.GetType("System.String")));
                  dt1.Columns.Add(new DataColumn("MY", Type.GetType("System.String")));
                  row = dt1.NewRow();
                  row["Description"] = "WOOOO";
                  row["ROXORZZOZO!!"] = "EOOOOOOOOOOOOOOOOOOOOO!";
                  row["MY"] = "My time to shine!";
                  dt1.Rows.Add(row);
                  row = dt1.NewRow();
                  row["Description"] = "MO!";
                  row["ROXORZZOZO!!"] = "EOOOO!";
                  row["MY"] = "My time to dine!";
                  dt1.Rows.Add(row);
                  row = dt1.NewRow();
                  row["Description"] = "WOOOO";
                  row["ROXORZZOZO!!"] = "EOOOOOOOOOOOOOOOOOOOOO!Hey Guys,Today(Thursday) I need to leave early at three to take care of some personal business.  Also, next Wednesday I’m going to be out of the office all day, taking a welding certification test.  I’ll also send out an OOO form.";
                  row["MY"] = "My time to be fine!";
                  dt1.Rows.Add(row);
  
                  dt2.Columns.Add(new DataColumn("Description", Type.GetType("System.String")));
                  dt2.Columns.Add(new DataColumn("ROXORZZOZO!!", Type.GetType("System.String")));
                  dt2.Columns.Add(new DataColumn("MY", Type.GetType("System.String")));
                  row = dt2.NewRow();
                  row["Description"] = "Description";
                  row["ROXORZZOZO!!"] = "ROXORZZOZO!!";
                  row["MY"] = "MY";
                  dt2.Rows.Add(row);
  
                  dt3.Columns.Add(new DataColumn("Row Numbers", Type.GetType("System.String")));
                  row = dt3.NewRow();
                  row["Row Numbers"] = "1";
                  dt3.Rows.Add(row);
                  row = dt3.NewRow();
                  row["Row Numbers"] = "2";
                  dt3.Rows.Add(row);
                  row = dt3.NewRow();
                  row["Row Numbers"] = "3";
                  dt3.Rows.Add(row);
                  GridView3.DataSource = new DataView(dt3);
                  GridView2.DataSource = new DataView(dt2);
                  GridView4.DataSource = new DataView(dt1);
                  GridView2.DataBind();
                  GridView3.DataBind();
                  GridView4.DataBind();
                  SynchGridviews(GridView2, GridView3, GridView4);
              }
          }
  
      protected void SynchGridviews(GridView top, GridView left, GridView body)
          {
              if (top.Width.Value &gt; body.Width.Value)
              {
                  body.Width = top.Width;
              }
              else
              {
                  top.Width = body.Width;
              }
  
              if (left.Height.Value &gt; body.Height.Value)
              {
                  body.Height = left.Height;
              }
              else
              {
                  left.Height = body.Height;
              }
              GridView2.DataBind();
              GridView3.DataBind();
              GridView4.DataBind();
          }
  
          protected void Button1_Click(object sender, EventArgs e)
          {
              SynchGridviews(GridView2, GridView3, GridView4);
          }
  </code></pre>