Welcome to Julian Kuiters Friday, October 19 2018 @ 09:06 AM AEDT

How to hide a property from a datasource when binding in ASP.Net design view

.NET Programming

Creating your own custom classes for business objects and object datasources is a great way to provide and object model for databases.

But some classes might contain properties that you don't expect to show to end users when they are bound to a DataGrid, FormView or other databound control.

Luckily there is an attribute that you can attach to properties that you want automatically hidden from databound controls:

[Browsable(false)]

To hide a property from databinding simply place the Browsable(false) attribute immediately before your property declaration

Example:

[Browsable(false)]
 public int MyProperty {
    get {
       // Insert code here. 
       return 0;
    }
    set {
       // Insert code here.
    }
 }