I have a GridView with a DataSource
(SQL Database). I want to hide a column, but still be able to access the value when I select the record. Can someone show me
You can use DataKeys for retrieving the value of such fields, because (as you said) when you set a normal BoundField
as visible false you cannot get their value.
In the .aspx
file set the GridView
property
DataKeyNames = "Outlook_ID"
Now, in an event handler you can access the value of this key like so:
grid.DataKeys[rowIndex]["Outlook_ID"]
This will give you the id at the specified rowindex of the grid.