我正在Visual Studio for SharePoint 2010中创建自定义列表定义。在列表定义元素文件中,我为列表实例提供了一些默认值,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="News"
OnQuickLaunch="FALSE"
TemplateType="10000"
Url="Lists/News"
Description="Contains news articles related to happenings at Corporate.">
<Data>
<Rows>
<Row>
<!-- Default list data -->
<Field Name="Photo">http://myserver/sites/foobar/Style%20Library/Images/Custom/myimage.png</Field>
<Field Name="Title">My Title</Field>
<Field Name="Body">My article.</Field>
<Field Name="Modified">12-21-2012</Field>
<Field Name="Author">99;#mydomain\bsmith</Field>
<Field Name="Expires">01-22-2013</Field>
</Row>
</Rows>
</Data>
使用上述值成功创建默认列表,但“照片”和“作者”列显示为空白。关于如何正确填充这些列的任何想法?我知道照片网址是有效的,因为我可以浏览它。另一篇帖子向我指出了作者列的“99;#”前缀 - 没有前缀,列表中的每一列都显示为空白。
此外,以下是列表架构字段,如果重要:
<Field ID="{d3a92d97-2b77-4a25-9698-3ab54874bc17}"
Name="Photo" ShowInNewForm="TRUE" ShowInEditForm="TRUE"
Type="Image" DisplayName="Photo"
Required="TRUE"></Field>
<Field ID="{d3a92d97-2b77-4a25-9698-3ab54874bc11}"
Name="Title"
Type="Text" DisplayName="Title"
Required="TRUE"></Field>
<Field ID="{d3a92d97-2b77-4a25-9698-3ab54874bc16}"
Name="Body"
Type="Note" DisplayName="Body"
Required="TRUE" NumLines="100"></Field>
<Field ID="{d3a92d97-2b77-4a25-9698-3ab54874bc13}"
Name="Modified"
Type="DateTime" DisplayName="Modified"
Required="TRUE"></Field>
<Field ID="{d3a92d97-2b77-4a25-9698-3ab54874bc14}"
Name="Author"
Type="Text" DisplayName="Author"
Required="FALSE"></Field>
<Field ID="{d3a92d97-2b77-4a25-9698-3ab54874bc15}"
Name="Expires"
Type="DateTime" DisplayName="Expires"
Required="FALSE"></Field>
答案 0 :(得分:4)
尝试在列表实例中配置这样的字段数据。
<Field Name="Photo"><![CDATA[<IMG SRC="/sites/foobar/Style%20Library/Images/Custom/myimage.png"></IMG>]]></Field>