title: Hide BoundField's but still be able to get values with C#
body: <p>I have a grid view and am using a variety of data:</p>
  
  <pre><code>&lt;asp:BoundField DataField="Catagory" HeaderText="Support Catagory" SortExpression="Catagory" /&gt;
  &lt;asp:BoundField DataField="AppName" HeaderText="Application Name" SortExpression="IncidentNumber" /&gt;
  &lt;asp:BoundField DataField="IncidentNumber" HeaderText="Incident #" SortExpression="IncidentNumber" /&gt;
  &lt;asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours" /&gt;
  &lt;asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /&gt;
  &lt;asp:BoundField DataField="CreatedDate" HeaderText="Created Date" SortExpression="CreatedDate" /&gt;
  &lt;asp:BoundField DataField="PK_DailyTaskHours" HeaderText="" SortExpression="PK_DailyTaskHours" ReadOnly="true" /&gt;
  &lt;asp:BoundField DataField="PK_NonScrumStory" HeaderText="" SortExpression="PK_NonScrumStory" ReadOnly="true" /&gt;
  </code></pre>
  
  <p>The last two columns however I don't want to show, I am using it so I can retrieve the primary keys with this C# code:</p>
  
  <pre><code>    string dailyTaskHoursPK = (string)e.Values["PK_DailyTaskHours"].ToString();
      string nonScrumStoryPK = (string)e.Values["PK_NonScrumStory"].ToString();
      SqlDataSource4.DeleteParameters["dailyTaskHoursPK"].DefaultValue = dailyTaskHoursPK;
      SqlDataSource4.DeleteParameters["nonScrumStoryPK"].DefaultValue = nonScrumStoryPK;
  </code></pre>
  
  <p>However, I don't want to display last two columns. But when I set:</p>
  
  <pre><code>Visible="false"
  </code></pre>
  
  <p>And try to run the program I get the following error:</p>
  
  <p>Object reference not set to an instance of an object.</p>
  
  <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
  
  <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</p>
  
  <p>What am I doing wrong? How do I prevent the user from seeing those fields?</p>