如何编辑SQL Server的XML数据字段asp.net动态数据 [英] How to edit a SQL Server XML data field with asp.net Dynamic Data
本文介绍了如何编辑SQL Server的XML数据字段asp.net动态数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须根据各地asp.net 3.5的动态数据功能的网站。一切都工作的伟大,但我想通过柱XML数据类型添加标记功能。我所做的列,并添加适当的模式,但它显示为只读和脚手架将不显示或修改字段。
所以,我有几个问题:
- 需要什么条件才能做使我的脚手架看到这个XML列?
- 我会如何通过支架编辑标签,而不直接编辑所有的XML?
- 我会在元数据中添加逻辑到的getter / setter?
- presumably我需要一个定制fieldTemplate,我将XML解析补充呢?
解决方案
我希望这是很有帮助的。至于你提到,你必须为你的XML数据的字段模板。
[MetadataType(typeof运算(DocumentMetadata))]
[显示名称(文档)]
公共部分类文档{ [ScaffoldColumn(真)
[显示(名称=一些XML)]
公共字符串SomeXml
{
得到
{
返回\"<note><to>Joe</to><from>Mary</from><heading>Reminder</heading><body>Hello世界&LT; /身体GT;&LT; /注&gt;中
}
}
}公共类DocumentMetadata
{
[ScaffoldColumn(假)]
公共对象ID {搞定;组; } [显示(名称=类型)
公共对象DocumentType {搞定;组; } [UIHint(CustomXmlFieldTemplate)]
[显示(名称=一些XML)]
公共对象SomeXml {搞定;组; }
}
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:
- What do I need to do in order to enable my scaffold to see this xml column?
- 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?
解决方案
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; }
}
这篇关于如何编辑SQL Server的XML数据字段asp.net动态数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文