How to use a hidden Boundfield in a GridView in ASP.NET?

Drew picture Drew · Feb 11, 2011 · Viewed 16.8k times · Source

I am binding a GridView using a DataSource in asp.net, and i would like to have some hidden BoundFields so I can access those values in my RowDataBound Function. However, when I set Visible="False" on these BoundFields the values do not get set and are always blank in the RowDataBound function.

Is there a way to do this? I've seen some suggestions of setting the style on the BoundField to hidden but this did not work for me either. Ideally I don't even want a column created in the gridview, I just want these values to be hidden so I can access them. Thanks!

Answer

RandomWebGuy picture RandomWebGuy · Feb 11, 2011

Odd, How are you doing it? I know I've done this before using:

<asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Eval("ColumnName")%>'/>