I have a grid view and am using a variety of data:
<asp:BoundField DataField="Catagory" HeaderText="Support Catagory" SortExpression="Catagory" />
<asp:BoundField DataField="AppName" HeaderText="Application Name" SortExpression="IncidentNumber" />
<asp:BoundField DataField="IncidentNumber" HeaderText="Incident #" SortExpression="IncidentNumber" />
<asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="CreatedDate" HeaderText="Created Date" SortExpression="CreatedDate" />
<asp:BoundField DataField="PK_DailyTaskHours" HeaderText="" SortExpression="PK_DailyTaskHours" ReadOnly="true" />
<asp:BoundField DataField="PK_NonScrumStory" HeaderText="" SortExpression="PK_NonScrumStory" ReadOnly="true" />
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:
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;
However, I don't want to display last two columns. But when I set:
Visible="false"
And try to run the program I get the following error:
Object reference not set to an instance of an object.
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.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
What am I doing wrong? How do I prevent the user from seeing those fields?