views:

30

answers:

3

This is simple. All I want to do is insert a hidden column into an asp:Griview that I'll be able to access through javascript. Any pointers?

A: 

Add to it the CSS property display:none. It will be unvisible but still present in the markup.

However this is not secure as the customer might unlock this column by using tools like FireBug which allows to override properties.

Developer Art
Don't worry theres nothing secure in here. So where do I apply this style? Item template? This was my initial reaction also but I couldn't get it to take effect.
m.edmondson
A: 

You can hide a column by setting its CssClass property, e.g:

<style>
.hidden {display:none;}
</style>

...

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
    <Columns>
        <asp:BoundField DataField="Id" ItemStyle-CssClass="hidden"
            HeaderStyle-CssClass="hidden" />
        <asp:BoundField DataField="Title" />
    </Columns>
</asp:GridView>
M4N
All the answers were correct but I've given the tick to this was as it was more fully answered.
m.edmondson
A: 

Item attribute

ItemStyle-CssClass="hidden"

css class

.hidden{ display: none; }

Tim B James