Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We are using sharepoint moss 2007 and have have multiple document libraries that all have the same fields and setup but have different contents.

We want to be able to specify with a query string the name of the document library and have the sharepoint dataformwebpart display the data from that document library.

Right now we seem to only have it display data from a hard-coded document library which is specified via the ListID as GUID. We have to set the data source via a document library name not a guid.

the most similar posts we found are at

http://blogs.msdn.com/b/joshuag/archive/2009/04/06/dataformwebpart-parameters-and-parameterbindings.aspx

and

http://www.neilrichards.net/blog/?p=42

and

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spdatasource.selectparameters.aspx

Here's the code for the dataformwebpart copied from sharepoint designer 2007 - anyone have any ideas?

        <WebPartPages:DataFormWebPart runat="server" __markuptype="vsattributemarkup" ViewFlag="10489857" ViewContentTypeId="0x" DetailLink="#" Width="" Height="" FrameState="Normal" IsIncluded="true" IsVisible="true" Dir="Default" AllowRemove="True" AllowZoneChange="false" AllowMinimize="false" Description="This is the document library that holds all the documents that are uploaded by user" MissingAssembly="Cannot import this Web Part." PartImageSmall="" PartImageLarge="" PartOrder="2" DisplayName="Part-I" ListName="" Title="Uploaded Documents (1)" FrameType="Default" NoDefaultStyle="TRUE" __WebPartId="{A3E42BB9-0972-4783-A97C-CAE2C5DD34D1}" id="g_a3e42bb9_0972_4783_a97c_cae2c5dd34d1" pagesize="100" showwithsampledata="false" __AllowXSLTEditing="true" WebPart="true"><DataSources><SharePoint:SPDataSource runat="server" IncludeHidden="true" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;GroupBy Collapse=&quot;FALSE&quot; GroupLimit=&quot;100&quot;&gt;&lt;FieldRef Name=&quot;PartNumber&quot;/&gt;&lt;FieldRef Name=&quot;DocumentCategory&quot;/&gt;&lt;/GroupBy&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;Created&quot;/&gt;&lt;/OrderBy&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;PartNumber&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;I&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name=&quot;ContentTypeId&quot;/&gt;&lt;FieldRef Name=&quot;FileLeafRef&quot;/&gt;&lt;FieldRef Name=&quot;File_x0020_Type&quot;/&gt;&lt;FieldRef Name=&quot;HTML_x0020_File_x0020_Type&quot;/&gt;&lt;FieldRef Name=&quot;_SourceUrl&quot;/&gt;&lt;FieldRef Name=&quot;Title&quot;/&gt;&lt;FieldRef Name=&quot;TemplateUrl&quot;/&gt;&lt;FieldRef Name=&quot;ProjectName&quot;/&gt;&lt;FieldRef Name=&quot;PartNumber&quot;/&gt;&lt;FieldRef Name=&quot;Section&quot;/&gt;&lt;FieldRef Name=&quot;DataNumber&quot;/&gt;&lt;FieldRef Name=&quot;DocumentCategory&quot;/&gt;&lt;FieldRef Name=&quot;DoEFileNameSuffix&quot;/&gt;&lt;FieldRef Name=&quot;Archived&quot;/&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;FieldRef Name=&quot;ContentType&quot;/&gt;&lt;FieldRef Name=&quot;Created&quot;/&gt;&lt;FieldRef Name=&quot;Author&quot;/&gt;&lt;FieldRef Name=&quot;Modified&quot;/&gt;&lt;FieldRef Name=&quot;Editor&quot;/&gt;&lt;FieldRef Name=&quot;_HasCopyDestinations&quot;/&gt;&lt;FieldRef Name=&quot;_CopySource&quot;/&gt;&lt;FieldRef Name=&quot;_ModerationStatus&quot;/&gt;&lt;FieldRef Name=&quot;FileRef&quot;/&gt;&lt;FieldRef Name=&quot;FileDirRef&quot;/&gt;&lt;FieldRef Name=&quot;Created_x0020_Date&quot;/&gt;&lt;FieldRef Name=&quot;File_x0020_Size&quot;/&gt;&lt;FieldRef Name=&quot;FSObjType&quot;/&gt;&lt;FieldRef Name=&quot;CheckedOutUserId&quot;/&gt;&lt;FieldRef Name=&quot;IsCheckedoutToLocal&quot;/&gt;&lt;FieldRef Name=&quot;CheckoutUser&quot;/&gt;&lt;FieldRef Name=&quot;CheckedOutTitle&quot;/&gt;&lt;FieldRef Name=&quot;_CheckinComment&quot;/&gt;&lt;FieldRef Name=&quot;_UIVersion&quot;/&gt;&lt;FieldRef Name=&quot;_UIVersionString&quot;/&gt;&lt;FieldRef Name=&quot;ParentVersionString&quot;/&gt;&lt;FieldRef Name=&quot;ParentLeafName&quot;/&gt;&lt;FieldRef Name=&quot;PermMask&quot;/&gt;&lt;/ViewFields&gt;&lt;/View&gt;" id="datasource1" DataSourceMode="List" UseInternalName="true" Scope="Recursive"><SelectParameters><asp:Parameter Name="ListID" DefaultValue="{8e4a5e33-9651-4065-bee6-bb2b4f7ee384}"/><asp:Parameter Name="StartRowIndex" DefaultValue="0"/><asp:Parameter Name="nextpagedata" DefaultValue="0"/><asp:Parameter Name="MaximumRows" DefaultValue="100"/><asp:Parameter Name="ListName" DefaultValue="02fab8b7d15674a1b11e026761434512" /><asp:Parameter Name="WebID" DefaultValue="RootWeb" /></SelectParameters>  </SharePoint:SPDataSource></DataSources><ParameterBindings>     <ParameterBinding Name="PageUrl" Location="Postback;Connection;CAMLVariable"/>      <ParameterBinding Name="PagePath" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="HttpHost" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="HttpPath" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="List" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="URL_Display" Location="Postback;Connection;CAMLVariable"/>      <ParameterBinding Name="HttpVDir" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="View" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="FilterLink" Location="Postback;Connection;CAMLVariable"/>       <ParameterBinding Name="Language" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="dvt_adhocmode" Location="Postback;Connection;CAMLVariable"/>        <ParameterBinding Name="dvt_fieldsort" Location="Postback;Connection;CAMLVariable"/>        <ParameterBinding Name="dvt_sortfield" Location="Postback;Connection;CAMLVariable"/>        <ParameterBinding Name="dvt_groupfield" Location="Postback;Connection;CAMLVariable"/>       <ParameterBinding Name="dvt_sortdir" Location="Postback;Connection;CAMLVariable"/>      <ParameterBinding Name="dvt_filterfield" Location="Postback;Connection;CAMLVariable"/>      <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="dvt_p2plinkfields" Location="Postback;Connection;CAMLVariable"/>        <ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="dvt_sorttype" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="dvt_apos" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="filterParam" Location="Postback;Connection"/>       <ParameterBinding Name="ImagesPath" Location="Postback;Connection;CAMLVariable"/>       <ParameterBinding Name="ListUrlDir" Location="Postback;Connection;CAMLVariable"/>       <ParameterBinding Name="EMail" Location="Postback;Connection;CAMLVariable"/>        <ParameterBinding Name="Userid" Location="Postback;Connection;CAMLVariable"/>       <ParameterBinding Name="URL_DISPLAY" Location="Postback;Connection;CAMLVariable"/>      <ParameterBinding Name="URL_EDIT" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="URL_Edit" Location="Postback;Connection;CAMLVariable"/>     <ParameterBinding Name="URL_Lookup" Location="Postback;Connection;CAMLVariable"/>       <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>        <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>     <ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>        <ParameterBinding Name="dvt_filterfields" Location="Postback;Connection"/>      <ParameterBinding Name="dvt_partguid" Location="Postback;Connection"/>      <ParameterBinding Name="ListName" Location="QueryString(DocLib)"/>      <ParameterBinding Name="StartRowIndex" Location="None" DefaultValue="0"/>       <ParameterBinding Name="nextpagedata" Location="None" DefaultValue="0"/>        <ParameterBinding Name="MaximumRows" Location="None" DefaultValue="100"/>   </ParameterBindings> 
share|improve this question

1 Answer 1

You can do this with DataSourceMode="CrossList", both to display the documents as well as to determine the available Document Libraries. Use a parameter to grab the Query Strng value and then filter your DVWP with that value.

EDIT 2011-07-08:

If you only have the list name and not the GUID, then you can filter on the list properties. See http://sympmarc.com/2009/02/26/10065/

share|improve this answer
    
the only problem with that solution is that it requires a ListID - I do not have a ListID - I have a ListName that is passed on the querystring - is there a way to lookup the listid from the listname using this method - or maybe I can do this using your spservice module in javascript and append a querystring value of the listid and use that instead? –  Anonymous Oct 7 '10 at 14:43
    
tried hardcodeding ID on CrossList but can't find an example - I'm forced into the markup after I change it from "List" to "CrossList" and add the <Web> and <List> in the selectcommand (tried before and after "View") it was unable to preview in sharepoint designer 2007 and did not work when saved and refreshed in the browser. I'm new to using the DVWP and SPDataSource so I'm finding myself trying things without a solid example and that has me really in the dark. Do you know where an example cross list is that is using a DVWP (data view web part) that is a converted DLWP (data list web part)? –  Anonymous Oct 7 '10 at 17:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.