Mano
Mano

Reputation: 445

Hide a Column in datagrid, without setting column.visble=false

 <asp:BoundField DataField="TimeRead" ItemStyle-Width="25%"  HeaderText="TimeRead" SortExpression="TimeRead" />
 <asp:BoundField DataField="Name" ItemStyle-Width="45%" HeaderText="Name" SortExpression="Name" />
 <asp:BoundField DataField="Email" ReadOnly="True" Display="none" HeaderText="Email" SortExpression="Email" />

How Can I hide the Email column in the datagrid., I dont Want to use column.visible property. How Can i hide it using css properties or anyother method. Thanks

Upvotes: 1

Views: 3005

Answers (1)

Chuck Callebs
Chuck Callebs

Reputation: 16441

<asp:BoundField DataField="Email" ItemStyle-Width="45%" HeaderText="Email" SortExpression="Email">
   <ItemStyle CssClass="boundfield-hidden" />
   <HeaderStyle CssClass="boundfield-hidden" />
</asp:BoundField>

That's how you add a CSS class directly to the bound field.

Now, in your css file, just add the following:

.boundfield-hidden {
   display: none;
}

Upvotes: 8

Related Questions