title: How to Stretch Gridview width inside a Div or a Panel in ASP.Net
body: <p><a href="https://i.stack.imgur.com/ZaJE7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZaJE7.jpg" alt="enter image description here"></a></p>
  
  <p>Based on the image above. I have a gridview that I like to be stretched, fixed containing the whole div that it is paneled inside. The problem is when it automatically adjust based on the contents width.</p>
  
  <p>The gridview is incorporated with javascript commands that make the header fixed. I can actually make the desired output by putting a <strong>width=100%</strong> property in the gridview. However since it has jquery command injectedl, when I include the width property it is resulting to this</p>
  
  <p><a href="https://i.stack.imgur.com/4qxkF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4qxkF.jpg" alt="enter image description here"></a></p>
  
  <p>here are the codes</p>
  
  <pre><code>     &lt;div class="GridviewPanelBody"&gt;
  
  
        &lt;asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" Font-Size="Smaller" EmptyDataText="No Records Found" ShowHeaderWhenEmpty="True"  AutoGenerateColumns="false" &gt;
  &lt;emptydatarowstyle backcolor="white" forecolor="black"/&gt;             
  &lt;AlternatingRowStyle BackColor="White" /&gt;
  
      &lt;Columns&gt;
          &lt;asp:BoundField HeaderText="Location" DataField="locationd" /&gt;
          &lt;asp:BoundField HeaderText="Retail Partner" DataField="name"   /&gt;
          &lt;asp:BoundField HeaderText="FL Area" DataField="sqm"   /&gt;
          &lt;asp:BoundField HeaderText="Previous Month" DataField="PreviousMonth" DataFormatString="{0:#,##0.00;(#,##0.00);0}"  /&gt;
           &lt;asp:BoundField HeaderText="Current Month" DataField="CurrentMonth" DataFormatString="{0:#,##0.00;(#,##0.00);0}" /&gt;
           &lt;asp:BoundField HeaderText="Last Year Month" DataField="LastYearMonth" DataFormatString="{0:#,##0.00;(#,##0.00);0}" /&gt;
            &lt;asp:BoundField HeaderText="Sales/SQM" DataField="SALES/SQM"  DataFormatString="{0:#,##0.00;(#,##0.00);0}"/&gt;
            &lt;asp:BoundField HeaderText="Inc/Dec%" DataField="INC/DEC%"  DataFormatString="{0:#,##0.00;}" /&gt;
  
           &lt;/Columns&gt;
  
         &lt;FooterStyle BackColor="#CCCC99" /&gt;
         &lt;HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" Height="25px"/&gt;
         &lt;PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /&gt;
       &lt;RowStyle BackColor="#F7F7DE" /&gt;
       &lt;SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /&gt;
        &lt;SortedAscendingCellStyle BackColor="#FBFBF2" /&gt;
        &lt;SortedAscendingHeaderStyle BackColor="#848384" /&gt;
        &lt;SortedDescendingCellStyle BackColor="#EAEAD3" /&gt;
        &lt;SortedDescendingHeaderStyle BackColor="#575357" /&gt;
    &lt;/asp:GridView&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>part of the css</p>
  
  <pre><code> .GridviewPanelBody
  {
               background-color: #FaFaFa;
  
               margin-left: auto;
  
               margin-right: auto;
  
               overflow: auto;
  
               height: auto;   
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/aQ9Ui.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aQ9Ui.jpg" alt="enter image description here"></a></p>