title: Freeze Grid View Header
body: <p>I am used two table first one for header and other one for body. From the JavaScript i am changing the header table each column width which same as body table. Each time on dropdownlist select index changes grid bind operation performs.Each time column width change for that I am use below JavaScript.</p>
  
  <p>Here I am writing JavaScript Code :</p>
  
  <pre><code>jQuery(document).ready(function () {
    var headergrid = $('#gridHeader').find("table")[0];
    var bodygrid = $('#bodyHeader').find("table")[0];
    var headerCellWidths = new Array();
  
    for (var i = 0; i &lt; bodygrid.getElementsByTagName('TH').length; i++) {
      headerCellWidths[i] = bodygrid.getElementsByTagName('TH')[i].offsetWidth;
    }
  
    for (var i = 0; i &lt; headerCellWidths.length; i++) {
      headergrid.getElementsByTagName('TH')[i].style.width = parseInt(headerCellWidths[i]) + 'px';
    }
  });
  </code></pre>
  
  <p>ASP CODE :</p>
  
  <pre><code>&lt;div style="height: 34px; overflow: auto" id="gridHeader"&gt;
    &lt;table id="tbltemp" width="856px"&gt;
      &lt;tr id="temp"&gt;
        &lt;th&gt;
          TRANS ID
        &lt;/th&gt;
        &lt;th&gt;
          VC NO.
        &lt;/th&gt;
        &lt;th&gt;
          SUB NO.
        &lt;/th&gt;
        &lt;th&gt;
         DOMAIN
        &lt;/th&gt;
        &lt;th&gt;
          STATION
        &lt;/th&gt;
        &lt;th&gt;
          DTC
        &lt;/th&gt;
        &lt;th&gt;
          STATUS
        &lt;/th&gt;
        &lt;th&gt;
          REMARK
        &lt;/th&gt;
        &lt;th&gt;
          ENTERED DATETIME
        &lt;/th&gt;
        &lt;th&gt;
        &lt;/th&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  &lt;div style="width: 859px; height: 450px; overflow: auto;" id="bodyHeader"&gt;
    &lt;asp:GridView ID="gvViewData" runat="server" AutoGenerateColumns="False" DataKeyNames="EC_TRANS_ID"
      OnRowDataBound="gvViewRow_DataBound" OnDataBound="gvViewData_DataBound" OnRowCommand="gvViewData_RowCommand"
      Visible="False" BackColor="White" 
      OnSelectedIndexChanging="gvViewData_SelectedIndexChanging"
    &gt;
      &lt;Columns&gt;
        &lt;asp:BoundField DataField="EC_TRANS_ID" HeaderText="TRANS ID" ReadOnly="True"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="VC_NO" HeaderText="VC NO" ReadOnly="True"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="SUB_NO" HeaderText="SUB NO"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="RESERVED" HeaderText="Part No"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="DOMAIN_NAME" HeaderText="DOMAIN"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="STATION_ID" HeaderText="STATION"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="DTC_CODE" HeaderText="DTC"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="STATUS" HeaderText="STATUS"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="REMARK" HeaderText="REMARK"&gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:BoundField DataField="ENTERED_DATETIME" HeaderText="ENTERED DATETIME" &gt;
          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;/asp:BoundField&gt;
        &lt;asp:ButtonField CommandName="Prameters" Text="Parameter"&gt;
          &lt;ItemStyle /&gt;
        &lt;/asp:ButtonField&gt;
      &lt;/Columns&gt;
    &lt;/asp:GridView&gt;        
  &lt;/div&gt;
  </code></pre>
  
  <p>But issue is that if width set as 110px it assigned as 105px or 68px then its assigned as 72px. Please give me some suggestion.</p>