title: dynamically set width of a column in Gridview
body: <p>I am trying to dynamically set width of gridview columns but when I apply the following code, I see no change in the browser. </p>
  
  <p>.aspx code is: </p>
  
  <pre><code>    &lt;asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="5" CellSpacing="4" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" CellPadding="4" DataKeyNames="File_Name" GridLines="None" OnRowEditing="GridView1_RowEditing" OnRowDeleting="GridView1_RowDeleting" OnRowUpdated="GridView1_RowUpdated" OnRowUpdating="GridView1_RowUpdating" ForeColor="#333333" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnPageIndexChanging="GridView1_PageIndexChanging" AllowSorting="True" OnSorting="GridView1_Sorting" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_OnRowDataBound"&gt;
                          &lt;PagerSettings Mode="NumericFirstLast" FirstPageText="First" LastPageText="Last" PageButtonCount="10" Position="Bottom" /&gt;
                          &lt;AlternatingRowStyle BackColor="White" /&gt;
                          &lt;Columns&gt;
                              &lt;asp:TemplateField HeaderText="File"&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:LinkButton ID="lnkbtnFileName" runat="server" CommandArgument='&lt;%# Eval("File_Name") %&gt;' CommandName="Download" Text='&lt;%# Eval("File_Name") %&gt;'&gt;&lt;/asp:LinkButton&gt;
                                  &lt;/ItemTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                          &lt;/Columns&gt;
                          &lt;EditRowStyle BackColor="#2461BF" /&gt;
                          &lt;FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;
                          &lt;HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;
                          &lt;PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /&gt;
                          &lt;RowStyle BackColor="#EFF3FB" /&gt;
                          &lt;SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /&gt;
                          &lt;SortedAscendingCellStyle BackColor="#F5F7FB" /&gt;
                          &lt;SortedAscendingHeaderStyle BackColor="#6D95E1" /&gt;
                          &lt;SortedDescendingCellStyle BackColor="#E9EBEF" /&gt;
                          &lt;SortedDescendingHeaderStyle BackColor="#4870BE" /&gt;
  
  
                      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>.cs code is: </p>
  
  <pre><code>            protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
      {
          //SET WIDTH OF THE COLUMNS
          if (e.Row.RowType == DataControlRowType.Header)
          {
              e.Row.Cells[0].Width = 100; //DATE
              e.Row.Cells[1].Width = 100; //CUSTOMER
              e.Row.Cells[2].Width = 100; //DESTINATION
          }
      }
  </code></pre>
  
  <p>Can anyone notice where I might be going wrong? </p>