在我的DataFormWebPart中,我有一个引用和查询列表的'DataSourcesString‘属性。
根据DataFormWebPart显示在哪个页面上,我需要能够在“DataSourcesString”中配置查询(在下面的代码中将字符串“Dispute Resolution”参数化)。
有没有人知道是否有一种方法可以通过XSL编辑器或Paramter编辑器修改web部件来实现参数化?
与“DataSourcesString”相关的web部件代码片段如下
<property name="DataSourcesString" type="string"><%@ Register TagPrefix="sharepoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><sharepoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;/OrderBy&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;Primary&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Dispute Resolution&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" IncludeHidden="True" ID="datasource1">谢谢!我意识到如果没有截图,这可能不是那么清楚。
发布于 2010-03-05 01:24:31
您可以使用DataForm上的QueryString参数来完成此操作。我假设您只能导出‘re部件。因此,导出and部件并将.webpart保存到桌面。打开它并修改它,如下所示:
在DataSourcesString中,完全删除where子句:
<property name="DataSourcesString" type="string"><%@ Register TagPrefix="sharepoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><sharepoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" IncludeHidden="True" ID="datasource1">在<property name="ParameterBindings" type="string">节点中,添加:
<ParameterBinding Name="MyVariable" Location="QueryString(MyVar)"/>在add部件本身的XSL中,找到<xsl:param name="dvt_partguid" />并在其正下方添加:
<xsl:param name="MyVar" />最后,找到select="/dsQueryResponse/Rows/Row并将其修改为:
select="/dsQueryResponse/Rows/Row[@Primary='$MyVar']保存the部件,将其上载,现在您应该能够通过将MyVar=Whatever添加到查询字符串来对其进行过滤
发布于 2010-03-04 01:03:15
我发现在运行时操纵参数的唯一方法是在后台使用C#代码。
以下是所需的步骤:
https://stackoverflow.com/questions/2372516
复制相似问题