0
votes

I've developed a data form web part in SharePoint Designer 2010. The web part present a filtered view of a list along with edit and insert functions. I want to move the code out to Visual Studio into a solution I have for all our SP enhancements.

I exported the web part to a .webpart file from SP Designer and used that as the .webpart in a visual web part project, but when I deploy the project, the web part from Visual Studio doesn't have any data in it. The same web part deployed from SP Designer does have data in it.

I tried changing the VS web part .cs class to inherit from Microsoft.SharePoint.WebPartPages.DataFormWebPart, but that didn't fix the problem. Here's the .webpart file, any help is appreciated:

    <?xml version="1.0" encoding="utf-8"?>
<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="PipelineItemEditor.VisualWebPart1.VisualWebPart1, $SharePoint.Project.AssemblyFullName$" />
      <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="InitialAsyncDataFetch" type="bool">False</property>
        <property name="ChromeType" type="chrometype">TitleOnly</property>
        <property name="Title" type="string">My Pipeline Items</property>
        <property name="Height" type="string" />
        <property name="CacheXslStorage" type="bool">True</property>
        <property name="ListDisplayName" type="string" null="true" />
        <property name="AllowZoneChange" type="bool">False</property>
        <property name="AllowEdit" type="bool">False</property>
        <property name="XmlDefinitionLink" type="string" />
        <property name="DataFields" type="string" />
        <property name="Hidden" type="bool">False</property>
        <property name="ListName" type="string" null="true" />
        <property name="NoDefaultStyle" type="string">TRUE</property>
        <property name="AutoRefresh" type="bool">True</property>
        <property name="ViewFlag" type="string">8388621</property>
        <property name="Direction" type="direction">NotSet</property>
        <property name="AutoRefreshInterval" type="int">60</property>
        <property name="AllowConnect" type="bool">False</property>
        <property name="Description" type="string" />
        <property name="AllowClose" type="bool">False</property>
        <property name="ShowWithSampleData" type="bool">False</property>
        <property name="ParameterBindings" type="string">
          &lt;ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/&gt;
          &lt;ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/&gt;
          &lt;ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/&gt;
          &lt;ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)"/&gt;
          &lt;ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)"/&gt;
          &lt;ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)"/&gt;
          &lt;ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)"/&gt;
          &lt;ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)"/&gt;
          &lt;ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(core,noXinviewofY_DEFAULT)"/&gt;
          &lt;ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)"/&gt;
          &lt;ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,moreItemsParen)"/&gt;
          &lt;ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/&gt;
          &lt;ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/&gt;
        </property>
        <property name="Xsl" type="string" null="true" />
        <property name="CacheXslTimeOut" type="int">86400</property>
        <property name="WebId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
        <property name="ListUrl" type="string">Lists/Pipeline</property>
        <property name="DataSourceID" type="string" />
        <property name="FireInitialRow" type="bool">True</property>
        <property name="ManualRefresh" type="bool">False</property>
        <property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden, Mobile</property>
        <property name="ChromeState" type="chromestate">Normal</property>
        <property name="AllowHide" type="bool">False</property>
        <property name="PageSize" type="int">-1</property>
        <property name="SampleData" type="string" null="true" />
        <property name="BaseXsltHashKey" type="string" null="true" />
        <property name="AsyncRefresh" type="bool">True</property>
        <property name="HelpMode" type="helpmode">Modeless</property>
        <property name="ListId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
        <property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
        <property name="AllowMinimize" type="bool">False</property>
        <property name="TitleUrl" type="string">/Lists/Pipeline</property>
        <property name="CatalogIconImageUrl" type="string" />
        <property name="DataSourcesString" type="string" />
        <property name="GhostedXslLink" type="string">main.xsl</property>
        <property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
        <property name="DisplayName" type="string">All Pipeline Items</property>
        <property name="UseSQLDataSourcePaging" type="bool">True</property>
        <property name="Width" type="string" />
        <property name="ExportMode" type="exportmode">All</property>
        <property name="XslLink" type="string" null="true" />
        <property name="ViewContentTypeId" type="string">0x</property>
        <property name="HelpUrl" type="string" />
        <property name="XmlDefinition" type="string">
          &lt;View Name="{2F369D62-EFD0-4E6F-961D-BA71E4622076}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="All Pipeline Items" Url="/SitePages/pipelinetest.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png"&gt;
          &lt;Query&gt;
          &lt;Where&gt;
          &lt;Eq&gt;
          &lt;FieldRef Name="Author"/&gt;
          &lt;Value Type="Integer"&gt;
          &lt;UserID/&gt;
          &lt;/Value&gt;
          &lt;/Eq&gt;
          &lt;/Where&gt;
          &lt;OrderBy&gt;
          &lt;FieldRef Name="Created_x0020_Date" Ascending="FALSE"/&gt;
          &lt;/OrderBy&gt;
          &lt;GroupBy&gt;
          &lt;/GroupBy&gt;
          &lt;/Query&gt;
          &lt;ViewFields&gt;
          &lt;FieldRef Name="Edit"/&gt;
          &lt;FieldRef Name="PItemType"/&gt;
          &lt;FieldRef Name="PItemText"/&gt;
          &lt;FieldRef Name="PItemLink"/&gt;
          &lt;FieldRef Name="PItemDirection"/&gt;
          &lt;FieldRef Name="PItemPicture"/&gt;
          &lt;FieldRef Name="Created"/&gt;
          &lt;FieldRef Name="Related_x0020_Tags"/&gt;
          &lt;/ViewFields&gt;
          &lt;RowLimit Paged="TRUE"&gt;30&lt;/RowLimit&gt;
          &lt;Toolbar Type="Standard"/&gt;
          &lt;ViewStyle ID="17"/&gt;
          &lt;/View&gt;
        </property>
        <property name="Default" type="string">FALSE</property>
        <property name="TitleIconImageUrl" type="string" />
        <property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
        <property name="SelectParameters" type="string" />
      </properties>
    </data>
  </webPart>
</webParts>
1

1 Answers

0
votes

Cross posting answer from https://sharepoint.stackexchange.com/questions/24932/moving-web-part-out-of-sharepoint-designer-2010-to-visual-studio-2010/ in the interests of avoiding http://imgs.xkcd.com/comics/wisdom_of_the_ancients.png

Create a new webpart item in an empty SharePoint project.

Copy your exported webpart into the .webpart file

Remove the .cs file

Edit the elements.xml file to set the display name and such for your new web part

Deploy the solution

Load your version of the DFWP web part from the gallery.

In this case you don't need to create a new class, you're just creating a template instance of an existing webpart with pre-set configuration which is set in the .webpart file