Insert hidden column in asp:GridView but still available client side

m.edmondson picture m.edmondson · Oct 8, 2010 · Viewed 13.8k times · Source

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?

Answer

M4N picture M4N · Oct 8, 2010

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>