Sql – How to edit a SQL Server XML data field with asp.net Dynamic Data


I have a site based around asp.net 3.5's Dynamic Data feature. Everything's working great, but I would like to add a tagging feature via a column with an XML data type. I've made the column and added an appropriate schema, but it is showing up as read-only and the scaffold will not display or modify the field.

So, I have a few questions:

  1. What do I need to do in order to enable my scaffold to see this xml column?
  2. How would I go about editing the tags through the scaffold without directly editing all the xml?
    • Would I add logic to the getter/setter in the metadata?
    • Presumably I would need a custom fieldTemplate, would I add the xml parsing to it?

Best Solution

I hope this is helpful. As you mention, you would have to create a field template for your XML data. :

public partial class Document {

    [Display(Name = "Some Xml")]
    public string SomeXml
            return "<note><to>Joe</to><from>Mary</from><heading>Reminder</heading><body>Hello World</body></note>"

public class DocumentMetadata
    public object Id { get; set; }

    public object DocumentType { get; set; }

    [Display(Name="Some XML")]
    public object SomeXml { get; set; }