I have an Asp.Net 4.0 Dynamic Data website with a LINQ to SQL data context. One of the columns in the SQL Server database is NVARCHAR(MAX) and contains an XML fragment. I have mapped this to XElement in the .dbml file. I have added metadata for the class with a UIHint for the property and I have written a Custom Field template that shows the XML contents in a TreeView. Much like How to edit a SQL Server XML data field with asp.net Dynamic Data
Now I'd like to actually edit the data field. A simple text editor will do so I thought I'd copy the MultiLine_Edit field template. On the edit page it is indeed showing and I can edit the contents. But this approach turns out to be a bit too simple for when I press update, I get a red List of validation errors: The value is not valid.
at the top of the page.
I commented out the DynamicValidator, but now I get a ServerError instead that it cannot save my edits cause it fails at converting my edits from String to XElement.
I found an old post on the asp.net forums from someone trying to do the same thing but it does not show a solution.
So my question is: What should my XML_Edit field template look like?
Try using the XDocument
type instead, which is serializable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With