How to create custom properties in a DataFormWebPart
I have a custom web part that I am working on that has an XSL link property that connects it to a XSLT file that runs the web part. I am wanting to create another Boolean field that when checked, the web part will link to another XSLT file. I cannot use the get/set method because this is not a standard web part. I do not have a C# page that is driving this web part. I do have the .webpart file that has all of the values for the properties, and I think that this is where I need to put the code. I am just unsure of how to do this. Any help would be much appreciated. Here is a piece of the .webpart file:
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.DataFormWebPart, Microsoft.ShareP开发者_Python百科oint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="PageSize" type="int">-1</property>
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="Height" type="string" />
<property name="SampleData" type="string" null="true" />
<property name="AllowConnect" type="bool">True</property>
<property name="CatalogIconImageUrl" type="string" />
<property name="XslLink" type="string">/home/appbar.xslt</property>
<property name="AllowClose" type="bool">True</property>
<property name="Hidden" type="bool">False</property>
<property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
<property name="TitleIconImageUrl" type="string" />
<property name="ChromeState" type="chromestate">Normal</property>
<property name="FireInitialRow" type="bool">True</property>
<property name="Description" type="string" />
<property name="AllowMinimize" type="bool">True</property>
<property name="Xsl" type="string" null="true" />
<property name="ExportMode" type="exportmode">All</property>
<property name="AllowZoneChange" type="bool">True</property>
<property name="Default" type="string" />
<property name="UseSQLDataSourcePaging" type="bool">True</property>
<property name="ParameterBindings" type="string">
<ParameterBinding Name="ListName" Location="None" DefaultValue="MDocLinks"/>
<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
</property>
<property name="DisplayName" type="string" />
<property name="NoDefaultStyle" type="string">TRUE</property>
<property name="Title" type="string">MDock</property>
<property name="AllowHide" type="bool">True</property>
<property name="ViewFlag" type="string">0</property>
</properties>
</data>
</webPart>
</webParts>
This is the bulk of it. I did not want to fill up too much of the page. :)
the .webpart is simply a definition for the web part.The backend code already exists you are simply defining what assembly/class is responsible for processing.
To accomplish what you are referring to you will need to create a new web part in visual studio that inherits from the DataFormWebPart.
From this you can then add the additional property and conditional lookup logic.
You need to extend this webpart through C# code and then expose the following property as a connection.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.dataformwebpart.xsllink.aspx
To see how you can extend it, here is the example:
http://www.chaholl.com/archive/2010/01/26/extending-the-dataform-web-part-to-allow-custom-field-controls.aspx
精彩评论