Does the ReadOnly attribute do anything? RRS feed

  • Question

  • User-1961942910 posted

    (Using 3.5 SP1)

    I was trying to set one of my columns read-only using the MetaData, like this:


    public object WhenCreated { get; set; }


    The column still shows up as editable in the gridview and the detailsview.  I did read elsewhere in the forum that you can go into the ORM Designer and set the Read Only property for a column there, and that worked.  I would prefer not to do it there, as sometimes I make changes to my database and just completely wipe the model and re-add the tables.  That obviously blows away any settings for ReadOnly that were done in the model.

     Is there any way to force ReadOnly in my <table>.cs file?  If it worked like in my example code above, using the metadata, that would be great.  As it is, it doesn't seem like the ReadOnly attribute does anything.

    Wednesday, August 20, 2008 11:52 AM

All replies

  • User912930037 posted

    I tried this as well -- but didn't like that I had to flag the column in the designer. 

    I've been forced to create read-only versions of properties in my partial classes, with just a "getter". That seems to do the trick.

    Anyone else have a more elegant work-around using meta data?

    Wednesday, August 20, 2008 7:02 PM