Welcome to Julian Kuiters Thursday, August 16 2018 @ 03:02 PM AEST

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

  • Contributed by:
.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.
    }
 }