Print Page | Close Window

Why are the properties of a related object set to readonly?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=265
Printed Date: 01-Apr-2025 at 4:10pm


Topic: Why are the properties of a related object set to readonly?
Posted By: Customer
Subject: Why are the properties of a related object set to readonly?
Date Posted: 16-Jul-2007 at 11:05am
I have a issue while displaying the address for a contact in a tabview. Adderss, city  and postal code are displayed in a text box. Though we haven't set these properties to read only in the design view, they are greyed out at the run time. We should be able to edit these fields at the run time.



Replies:
Posted By: IdeaBlade
Date Posted: 16-Jul-2007 at 11:08am
This is a great question and one that developers new to DevForce often ask.
 
Your problem is that you are binding to properties of a related object.  It's true that you have done nothing to make these properties readonly, but DevForce makes access to these  properties readonly by default - for the good reason that it is unusual to want to change the value of a related object through an interface looking at the original object. Thus, while looking at an Employee, we could look at her address but we would typically change her address by popping up a dialog for that purpose or, perhaps, reserving real estate on the screen for that purpose. 
 
In addition, if you make a related  property editable, it can be confusing what the edit means.  For example, let us say that an employee's manager's name is "Nancy Davolio" and a user changes it to "Nancy Smith".  Does the employee have a new manager, or has Nancy's last name changed because she married Bob Smith.
 
If you really insist on editing a related poperty, you can set the editability of the control to "Optional".  This works, but before you go ahead and do this, ask yourself whether this is the best way to edit this related property.
 



Print Page | Close Window