title: Can width of a Gridview's column can be changed in percentage in codebehind?
body: <p>I have a <code>gridview</code> having 5 columns, and last column is visible to some members only.
  I want that when the last column<code>gvMessageList.Columns[4]</code> is inivisible, its width in percentage should be given to first column<code>gvMessageList.Columns[0]</code>.</p>
  
  <p>Please, let me know, how is it possible.</p>
  
  <p>My <code>GridView</code> is as follow:</p>
  
  <pre><code>&lt;asp:GridView ID="gvMessageList" runat="server" Width="100%" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
      DataKeyNames="MESSAGE_ID" CellPadding="4" PageSize="51" EmptyDataText="No Records Found." OnSorting="gvMessageList_Sorting"
      OnPageIndexChanging="gvMessageList_PageIndexChanging" OnRowDataBound="gvMessageList_RowDataBound" GridLines="None"
      CssClass="table table-bordered table-condensed table-hover table-striped"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="Subject" HeaderStyle-Width="30%" SortExpression="MESSAGE_SUBJECT" HeaderStyle-BackColor="#D9EDF7"
              HeaderStyle-ForeColor="#0088CC"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:HyperLink ID="hlnkMessageSubject" runat="server" Text='&lt;%# ((System.Data.DataRowView)Container.DataItem)["MESSAGE_SUBJECT"] %&gt;'
                      NavigateUrl='&lt;%# ((System.Data.DataRowView)Container.DataItem)["MESSAGE_URL"] %&gt;'&gt;
                  &lt;/asp:HyperLink&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="From" HeaderStyle-Width="14%" SortExpression="MESSAGE_FROM" HeaderStyle-BackColor="#D9EDF7"
              HeaderStyle-ForeColor="#0088CC"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:HyperLink ID="hlinkUser" runat="server" Text='&lt;%#((System.Data.DataRowView)Container.DataItem)["MESSAGE_FROM"] %&gt;'
                      NavigateUrl='&lt;%#((System.Data.DataRowView)Container.DataItem)["FROM_URL"] %&gt;'&gt;
                  &lt;/asp:HyperLink&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:BoundField DataField="CREATION_DATE" HeaderText="On" HeaderStyle-Width="15%" HeaderStyle-BackColor="#D9EDF7" HeaderStyle-ForeColor="#0088CC"
              SortExpression="CREATION_DATE" /&gt;
          &lt;asp:TemplateField HeaderText="To" HeaderStyle-Width="21%" HeaderStyle-BackColor="#D9EDF7" HeaderStyle-ForeColor="#0088CC"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblTo" runat="server"&gt;
                  &lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Broadcast" HeaderStyle-Width="20%" Visible="false" HeaderStyle-BackColor="#D9EDF7" HeaderStyle-ForeColor="#0088CC"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblBroadcast" runat="server"&gt;
                  &lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>In C# Codebehind:</p>
  
  <p>I want increased percentage of first column here:</p>
  
  <pre><code>gvMessageList.Columns[4].HeaderStyle.Dispose();
  gvMessageList.Columns[4].Visible = false;
  </code></pre>
  
  <p>Is it possible by using <code>gvMessageList.Columns[0].HeaderStyle.Width = ??</code> or something like it.</p>