[Mono-dev] DataSource's DataBind exposes difference between properties and attributes

Antti S. Lankila alankila at bel.fi
Fri Apr 4 04:50:45 EDT 2008


Something like this:

public class Item { public string ID, Text; }

var foo = new [] {
    new Item() { ID = "x", Text = "X" },
    new Item() { ID = "y", Text = "Y" },
};

is not a valid datasource to for instance asp:DataGrid. The problem is 
that DataGrid calls GetPropertyValue() which does not work against 
regular attributes, but only properties. Thus, to make this work, one 
has to write some property boilerplate for class Item:

public class Item {
    private string _ID, _Text;

    public string ID {
       get {
          return _ID;
       }
       set {
          _ID = value;
       }
    }
    etc.
}

Shouldn't it be against the very point of properties vs. attributes to 
expose the difference between them? Can this be changed, or is this a 
.Net snafu?

-- 
Antti


More information about the Mono-devel-list mailing list