Home All Groups Group Topic Archive Search About

Bug with new GridView object? Hidden column not working

Author
6 Feb 2006 8:09 PM
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

Author
7 Feb 2006 1:03 AM
Christopher Reed
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.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

Show quote
"Evian Spring" <evian_spr***@canada.com> wrote in message
news:1139256545.945323.272870@o13g2000cwo.googlegroups.com...
> 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
>

AddThis Social Bookmark Button