I See Sharp I See Sharp - 1 year ago 136
ASP.NET (C#) Question

How to hide a column (GridView) but still access its value?

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 how to do this?

This is the column I want to hide and still want to access its value:

<asp:BoundField DataField="Outlook_ID" HeaderText="OutlookID" />

I tried everything to hide the column (property
), but I can't access its value.

Thank you in advance.

Answer Source

If i am not mistaken, gridview does not hold the values of boundcolumns that have the attribute visible="false". 2 things you may do here, one (as explained in the answer from V4Vendetta) to use Datakeys. Or you can change your boundcolumn to a template field. And in the item template, add a control like label, make its visibility false and give your value to that label.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download