質問

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?

役に立ちましたか?

解決 2

LINQ to SQL and Dynamic Data do not play nice together.

So do not map the XML content to XElement. Map it to string instead.

You can use Custom Field Templates just fine, but base them on strings.

他のヒント

Try using the XDocument type instead, which is serializable.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top