title: Set Gridview Height as Percentage ASP.Net
body: <p>I have a gridview control on a page. My page all heights are in percentages. Since all divs are working fine. Only gridview does not accepting percentage because I put fixed header on gridview control to show its header.</p>
  
  <p>If I give pixles to its class, it accept and put scrollbar aside. But if I give percentage like 10% or 20% gridview fill with all records and expand till end.</p>
  
  <p>My code is as follows:</p>
  
  <p>css Class **</p>
  
  <pre><code>.containergrid {
      height: 10%;
      overflow: auto;
      background-color: forestgreen;
  }
  </code></pre>
  
  <p>gridview control **</p>
  
  <pre><code>&lt;div class="containergrid"&gt;
      &lt;asp:GridView ID="grdCost" runat="server" AutoGenerateColumns="False"
          CssClass="table table-hover table-striped" ShowHeader="false"
          DataKeyNames="CostID"
          OnRowCommand="grdCost_RowCommand" OnRowDataBound="grdCost_RowDataBound"
          BorderStyle="None" BorderWidth="0px" CellPadding="1" GridLines="None" Font-Size="Small"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="CostName"&gt;
                  &lt;ItemStyle CssClass="col-md-9 col-sm-9 col-xs-9"&gt;&lt;/ItemStyle&gt;
              &lt;/asp:BoundField&gt;
              &lt;asp:BoundField DataField="Percentage" DataFormatString="{0:0}%"&gt;
                  &lt;ItemStyle CssClass="col-md-1 col-sm-1 col-xs-1"&gt;&lt;/ItemStyle&gt;
              &lt;/asp:BoundField&gt;
              &lt;asp:BoundField DataField="Active"&gt;
                  &lt;ItemStyle CssClass="col-md-1 col-sm-1 col-xs-1"&gt;&lt;/ItemStyle&gt;
              &lt;/asp:BoundField&gt;
              &lt;asp:TemplateField HeaderText="Option"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:LinkButton ID="btnEdit" CommandName="editRecord"
                          CommandArgument='&lt;%# Eval("CostID") + "," + Eval("CostName") + "," + Eval("Percentage") + "," + Eval("Active")%&gt;' runat="server"&gt;
                      &lt;span class="glyphicon glyphicon-pencil" style="padding-left:30px"&gt;&lt;/span&gt;
                      &lt;/asp:LinkButton&gt;
  
                      &lt;asp:LinkButton ID="btnDelete" CommandName="deleteRecord"
                          CommandArgument='&lt;%# Eval("CostID") + "," + Eval("CostName")%&gt;' runat="server"&gt;
                          &lt;span class="glyphicon glyphicon-trash" aria-hidden="true"&gt;&lt;/span&gt;
                      &lt;/asp:LinkButton&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;ItemStyle CssClass="col-md-1 col-sm-1 col-xs-1 col-md-pull-1"&gt;&lt;/ItemStyle&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
  
          &lt;RowStyle BackColor="White" ForeColor="#333333" /&gt;
      &lt;/asp:GridView&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Please help. Thanks</p>