I have a grid view and I use various 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 do not want to show, I use it to get 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 do not want to display the last two columns. But when I installed:
Visible="false"
And try to run the program, I get the following error:
The reference to the object is not installed in the instance of the object.
Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for more information about the error and its occurrence in the code.
Exception Details: System.NullReferenceException: The object reference was not set to the object instance.
What am I doing wrong? How can I prevent a user from viewing these fields?
David tunnell
source share