If Gridview has any BoundField column for which visible property is set to "false" then that columns won't be rendered at runtime and you can not get value of hidden column.
if you try to get value of any cell of hidden column by using GV.Rows[i].Cell.Text then it returns nothing.
But there are Four ways to get value of hidden column -
I am taking an example of gridview that display addresses and has first column for "AddressID" that is hidden column and I am defining different ways to get value of "AddressID".
1. First Way -
(a). In Gridview set DataKeyNames property to hidden column id.
In following case set DataKeyNams to "AddressID" and set visible false to first column that displays "AddressID".
<asp:GridView ID="GVAddress" runat="server" AutoGenerateColumns="False" DataKeyNames="AddressID" >
(b). Value of hidden Column i.e. AddressID can be get by using DayaKeys property of Gridview.
2. Second Way -
(a). Create TemplateField column for hidden column in GridView,Add Label inside <ItemTemplate> And set visible to false for <asp:TemplateField>. So that TemplateField column won't be displayed at runtime.
(b). Use FindControl method of Row property of GridView to find Label control defined inside TemplateField column and assign it to label object and get value of label by using text property.
Label lblAddressId = (Label) GVAddress.Rows[index].FindControl("lblAddressId");
if (lblAddressId != null)
string strAddressId = lblAddressId.Text;
3. Third Way -
(a). Create a stylesheet for hiding grid column.
(b). Set HeaderStyle-CssClass and ItemStyle-CssClass property of column to hideGridColumn, that is defined in css, to hide column "AddressID" column.
HeaderStyle-CssClass=hideGridColumn ItemStyle-CssClass = hideGridColumn />
(c). Get value of hidden column by using Cell property.
4. Fourth Way -
Set visible to false of coulmn that is reuired to hide after bininging datasource to Gridview in Codebehind. In that case value of hidden column will be available by using GVAddress.Rows.Cell.Text.
GVAddress.DataSource = dtAddress;
GVAddress.Columns.Visible = false;