title: How to hide column and access it programatically in Gridview?
body: <p>I have a gridview which is bonded totally programatically . I want to hide some columns and also rich them to show them in the label.</p>
  
  <p>Here is my gridview :</p>
  
  <pre><code>&lt;Gridview ID=Gridview1 runat="server" &gt;&lt;/Gridview&gt;
  </code></pre>
  
  <p>I want to hide EmpID and UnitID . and want to show them in a label on the front-end side</p>
  
  <pre><code>EmpID  EmpName UnitID  UnitName    
  --------------------------------
   1      jack     4      MyUnit
  </code></pre>
  
  <p>I am trying to use this code , but it is not working even gives me error</p>
  
  <pre><code> if (GridForUnits.Columns.Count &gt; 1)
          {
             GridForUnits.Columns[1].Visible = false;
             //GridForUnits.Columns[1].Visible = false;
          }
  </code></pre>
  
  <p>Any Help appreciate</p>
  
  <p>Thanks</p>