views:

38

answers:

1

I have an object that I set as the datasource for a gridview - this works fine, I get a nice table on the page with a column for each public property.

But - I always want to hide one of the columns (but still need it available as a public property.

I'm using a clunky hide-column-on-row-created fix for now, but am looking for a better solution, like an attribute applied to the property to hide it from databinding.

Apparently this exists in winforms:

[Browsable(false)] // this stops Type from showing up in databound controls
public string Type { get; set; }

public string Description { get; set; }

Can anyone suggest a similar solution for ASP.NET?

Update:
I marked Rex M's answer as correct, because it answers the question, but if anyone else is interested in how to do this:
What eventually worked for me was to mark the property corresponding to the column I wanted to hide as internal instead of public.

+1  A: 

Looking at the reflected code for GridView.CreateAutoGeneratedColumns(PagedDataSource dataSource), it appears there are not any checks for attributes when it is scraping the datasource for properties. So, apparently not.

Rex M
OK, can't argue with that (thanks, never thought of using reflection).
MGOwen