Bug with new GridView object? Hidden column not working

  • Thread starter Thread starter Evian Spring
  • Start date Start date
E

Evian Spring

Hi,

In .NET 1.0, I was a able to set a hidden column (usually for an
internal ID) and be able to reference that column via code like this:
e.Row.Cells(0).Text. The example below shows a datagrid that would be
showing two columns and one of them would be hidden.


<Columns>
<asp:BoundField DataField="column1"
HeaderText="column1" ItemStyle-Width="100px" ReadOnly="true"
visible="false" />
<asp:BoundField DataField="column2"
HeaderText="column2" ItemStyle-Width="100px" ReadOnly="true" />
<asp:BoundField DataField="column3"
HeaderText="column3" ItemStyle-Width="100px" ReadOnly="true" />


</Columns>


However, with .NET 2.0 e.Row.Cells(0).Text will ALWAYS return a blank
value unless I make the field visible.


Is this a bug in .NET 2.0? or have they come up with a new way of
doing this?

PLEASE HELP.

Thanks,
Evian
 
This is the way it works now. If the field that you're hiding a primary
key, then you can add it to the DataKeys collection and access it through
that instead.
 
Back
Top