How do I hide a column only on the list page in AS

2020-07-27 03:03发布

问题:

This is somewhat similar to this question.

However, rather than wanting to hide a column all together, I am just looking to hide the column on the List.aspx page.

My specific example is that fields that are long (or at least nvarchar(MAX)) automatically hide from the List.aspx page as is but are still visible on the Edit.aspx page.

I would like to replicate this behaviour for other (shorter) columns.

Is this possible?

回答1:

You can create a custom page for the particular table you want to change. There's an example here.

Within your custom page, you can then set AutoGenerateColumns="false" within the asp:GridView control, and then define exactly the columns you want, like this:

<Columns>
    ...
    <asp:DynamicField DataField="Product" HeaderText="Product" />
    <asp:DynamicField DataField="Colour" HeaderText="Colour" />
</Columns>


回答2:

I think this solution is a really useful one, because it allow you to use the attribute model to specify which columns go where: http://csharpbits.notaclue.net/2008/10/dynamic-data-hiding-columns-in-selected.html



回答3:

if u r using bootstrap u can set like this

<asp:DynamicField DataField="Id" ItemStyle-CssClass="hidden" HeaderStyle-CssClass="hidden" FooterStyle-CssClass="hidden"/>