I think I figured out my problem. When I originally created the Text_RO.ascx user control, I only created "half". I needed to create both the text_RO.ascx AND Text_RO_Edit.ascx. I then had to make the Text_RO_Edit.ascx a literal just like the Text_RO.ascx.
The two user controls work together it appears.
Is this a correct assumption?
Hopefully you will see this post and be able to confirm this question for me and then mark this post as resolved? This was from last Friday.
Hi defyant_2004, I tried the ReadOnly attribute and it works perfect. I think you should place the ReadOnly attribute on top of the property in the auto generated data class, not in your own custom class. This is the easiest way to get things done, but the
only downside is we are modifying the auto gen class...
Sorry too quickly to jump to conclusion. Actually the ReadOnly atttribute doesn't seem to work correctly, at least I can't get it to work correctly. It does shows the column with just text string and without textbox in edit and insert, but if you try to
hit update it won't work, I guess when user hit the update link it tries to write to the ReadOnly field as well, despite user never change the value for that field (Because it's ReadOnly!). It still doen't work even after comment out the setter for that field
in the auto gen class.
Does anyone know how to get this to work? I am using 3.5 SP1, Linq to SQL
defyant_2004
Member
55 Points
337 Posts
Re: Show Field But Do Not Allow Editing
Jan 26, 2009 06:28 PM|LINK
Ricka6,
I think I figured out my problem. When I originally created the Text_RO.ascx user control, I only created "half". I needed to create both the text_RO.ascx AND Text_RO_Edit.ascx. I then had to make the Text_RO_Edit.ascx a literal just like the Text_RO.ascx. The two user controls work together it appears.
Is this a correct assumption?
Hopefully you will see this post and be able to confirm this question for me and then mark this post as resolved? This was from last Friday.
Thanks for help.
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: Show Field But Do Not Allow Editing
Jan 26, 2009 06:44 PM|LINK
Yes, that's why I originally suggested One approach would be to copy DynamicData\FieldTemplates\Text.ascx to TextRO_Edit
As when you copy the control, the code behind file is automatically copied too.
defyant_2004
Member
55 Points
337 Posts
Re: Show Field But Do Not Allow Editing
Jan 26, 2009 07:11 PM|LINK
Yes, it was the fact that I did not include _edit.
Thanks again for your help.
zhili
Member
23 Points
15 Posts
Re: Show Field But Do Not Allow Editing
Jan 15, 2010 11:59 PM|LINK
Hi defyant_2004, I tried the ReadOnly attribute and it works perfect. I think you should place the ReadOnly attribute on top of the property in the auto generated data class, not in your own custom class. This is the easiest way to get things done, but the only downside is we are modifying the auto gen class...
zhili
Member
23 Points
15 Posts
Re: Show Field But Do Not Allow Editing
Jan 16, 2010 02:27 AM|LINK
Sorry too quickly to jump to conclusion. Actually the ReadOnly atttribute doesn't seem to work correctly, at least I can't get it to work correctly. It does shows the column with just text string and without textbox in edit and insert, but if you try to hit update it won't work, I guess when user hit the update link it tries to write to the ReadOnly field as well, despite user never change the value for that field (Because it's ReadOnly!). It still doen't work even after comment out the setter for that field in the auto gen class.
Does anyone know how to get this to work? I am using 3.5 SP1, Linq to SQL
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: Show Field But Do Not Allow Editing
Jan 16, 2010 08:45 AM|LINK
Hi Zhili, have a look at these articles here : Making a Field Read-Only via the ReadOnlyAttribute – Dynamic Data and Making Individual Tables Read Only – Dynamic Data
Dynamic Data ReadOnly Attribute
Always seeking an elegant solution.