1

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?
Charles Bandes
  • 795
  • 8
  • 21
  • I was able to answer part 1 of the question by adding a UIHint for the xml column. This leads me to believe that the answer to part 2 will be creating a fieldTemplate designed for xml. – Charles Bandes Aug 20 '09 at 15:38

1 Answers1

2

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

[MetadataType(typeof(DocumentMetadata))]
[DisplayName("Documents")]
public partial class Document {

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

public class DocumentMetadata
{
    [ScaffoldColumn(false)]
    public object Id { get; set; }

    [Display(Name="Type")]
    public object DocumentType { get; set; }

    [UIHint("CustomXmlFieldTemplate")]
    [Display(Name="Some XML")]
    public object SomeXml { get; set; }
}
Ash Machine
  • 9,601
  • 11
  • 45
  • 52