SPDataSource and Rollups with the Data View

Hello -- my name is Eray Chou. I’m a Program Manager on the SharePoint Designer team. I focus mostly on data and app building features, and last release I worked on the Data View. During the last year or so, I also led development for the Application Templates for Windows SharePoint Services 3.0. I’m looking forward to posting tips and tricks about using the Data View (the Swiss Army Knife of web parts) and JavaScript (Duct Tape on the web). As MacGyver taught us – you accomplish some pretty cool things with a Swiss Army Knife and Duct Tape. For this post, I’ll give a brief overview of the SPDataSource control, as well as cover a pretty popular question: How do I create a view that rolls up data from across my site collection?

Data View vs. Data Form

Before we go deeper, you may have noticed that many of us use “Data View” and “Data Form” rather interchangeably. In Windows SharePoint Services v2, we shipped a web part called the DataViewWebPart (DVWP). This web part uses XSLT to transform data from Data Retrieval Services to HTML. In Windows SharePoint Services v3, we shipped a web part called the DataFormWebPart (DFWP). The DataFormWebPart still uses XSLT, but now uses ASP.Net 2.0 Data Source Controls for data access. In addition to “view” functionality, the DataFormWebPart also introduced “form” functionality to write back to various data sources. We use Data View generically to refer to the feature set and all of SharePoint Designer’s UI still uses the term Data View. Because this blog is SPD and Windows SharePoint Services v3 centric, we always mean DataFormWebPart (DFWP) under the covers unless otherwise specified.

Data Source Controls and SPDataSource

As noted, in Windows SharePoint Services, we redesigned Data Views to be an ASP.Net data bound control that uses ASP.Net 2.0 Data Source Controls for data access. To support this improvement, we also shipped a number of Data Source Controls for different data source types like the SPDataSource for SharePoint list data, XmlUrlDataSource for RSS/REST, and SoapDataSource for SOAP Web Services. Developers can also implement their own data source controls for other data source types. As long as a data source control implements the IDataSource or IHierarchicalDataSource, you can use the Data View to display data from that control.

Most of the Data View’s List-related features use the SPDataSource in List or ListItem mode. In these modes, SPDataSource returns multiple or single rows of list data respectively. However, in addition to these modes, the SPDataSource has a number of other modes that aren’t directly exposed in the UI: ListofLists, Webs, and CrossList mode. ListsofLists and Webs mode show the collection of lists and the collection of subwebs for a given Web site.

Here's a sample of SPDataSource:

<SharePoint:SPDataSource runat="server"



id="DataSrc1" >


<WebPartPages:DataFormParameter Name="ListID"






The key parts of the markup include:

  • DataSourceMode – type of WSS data to query. The valid modes are List, ListItem, ListOfLists, Webs, and CrossList.
  • SelectCommand – actual query for that data type. Some modes don’t require a query at all. In List mode, the SelectCommand roughly maps to the SPQuery object and accepts Collaborative Application Markup Language (CAML) fragments to specify things like the set of return fields, filtering, and sort order. The example does not specify any query, so the SPDataSource will return all fields and all items.
  • SelectParameter – each command expects a number of different parameters. These parameters can refer to the parameter bindings collection in the Data View, as well as take most ASP.Net types of parameters like Control and QueryString. The example only specifies a ListID GUID, so the SPDataSource will return data from the list with the corresponding ListID.

For more information on Collaborative Application Markup Language's query syntax, check out these links:

SPDataSource Parameteres

When in List or ListItem mode, the SelectParameters collection expects a number of well known parameter names to determine the appropriate list to bind to:

  • ListID – GUID that corresponds to a List’s ListID.
  • ListName – Display name for a List.
  • ListItemId – ID for a single item in ListItem mode
  • WebUrl – Url to the web. When not specified, SPDataSource uses the current web to resolve the previous parameters. You can also use this parameter to access lists in other Web sites in the same Site Collection assuming you have permissions to that list.

In the previous example, the ListID parameter was a static value and just used the value specified in DefaultValue. Parameters can also be dynamic and used inside a query, as demonstrated in the next example:

<SharePoint:SPDataSource runat="server"






<FieldRef Name='ContentType'/>

<Value Type='Text'>{ContentTypeName}</Value>





id="DataSrc1" >


<asp:QueryStringParameter Name="ContentTypeName"



<WebPartPages:DataFormParameter Name="ListID"






In this example, the SelectCommand specifies a filter for items of a specific content type. The SPDataSource uses curly braces to specify substitution parameters: {parametername}. Notice that the QueryStringParameter is named “ContentTypeName” and within the SelectCommand the Where clause is comparing a field value to “{ContentTypeName}”. At runtime, the value of ContentTypeName parameter is pulled from a QueryString variable called CType, and its value is substituted into the SelectCommand.

CrossList Mode

One of the most powerful new OM calls in Windows SharePoint Services v3 is the GetSiteData method on the SPWeb object. This method makes it possible to query for items across multiple lists in multiple Web sites in the same site collection. This is most often used for queries like, “show all tasks that are due today”, “show all documents created by me in the site collection”, or “show all announcements in the site collection”. The SPDataSource exposes this functionality when in CrossList mode.

<SharePoint:SPDataSource runat="server"


SelectCommand="<Webs Scope='Recursive'></Webs>

<Lists ServerTemplate='104' BaseType='0'></Lists>



<FieldRef Name='ID'/>

<FieldRef Name='ContentType'/>

<FieldRef Name='Title'/>



id="DataSrc1" >


The SelectCommand for SPDataSource in CrossList mode roughly maps to the SPSiteDataQuery object, much like how the SelectCommand in List mode roughly maps to the SPQuery object. The new pieces of syntax are the Lists and Webs elements.

  • Webs element – specifies the scope of the query. “Recursive” scope covers all web descended from the current Web site. When using this element with SPDataSource, use a closing element tag (</Webs>) as opposed to single element notation (<Webs />)
  • Lists element – limits the query to lists with a specific ServerTemplate or BaseType. In the example above, the element limits the query to Announcements lists (ServerTemplate='104'). See the description of the Type attribute for a list of ServerTemplate numbers: http://msdn2.microsoft.com/en-us/library/ms462947.aspx
  • Lists sub-elements
  1. <List ID="GUID"> - supports asking for specific lists by ListID.
  2. <WithIndex FieldId="GuidOfField" Type="Text" Value="" /> - limits the query to lists with indexed fields.

Create a view that shows all announcements in the site collection

Using SPD, the easiest way to create a Data View that uses a CrossList query is to design much of the view while in List mode, switch into code view, and add the additional elements by hand. Here are the steps to create a simple view that shows all announcements in the site collection.

  1. Open a Windows SharePoint Service v3 Team Site in SharePoint Designer.
  2. Insert a view on a the Announcements list with the Title, Body, and Modified fields.
    For more information on how to insert a Data View, see the articles here: http://office.microsoft.com/en-us/sharepointdesigner/CH100667641033.aspx
  3. At the top of the Data Source Details task pane, click “Announcements…” to open the data source properties for the current view.
  4. Click on Fields and remove all fields except ID, Title, Body, and Modified.
  5. Switch to code view, and search for DataSourceMode
  6. Change the value from List to CrossList
  7. Next search for selectcommand
  8. In the select command, type <Webs Scope='Recursive'></Webs> immediately after the opening quote, and leave the rest of the selectcommand as it. You should see something like this: selectcommand="<Webs Scope='Recursive'></Webs>&lt;View&gt; ...
  9. Save the page and browse to it (F12).

Hope you enjoyed my first post.

-- eray

Comments (112)

  1. Jonas says:

    Thanks for some great info!!!

    I have a question about accessing web services across Web Applications using the SoapDataSource.

    Unless the web application is using Kerberos authentication I can’t get this to work.

    I get an error saying:

    http://server/_vti_bin/webpartpages.asmx and http://server:85/_vti_bin/lists.asmx”>http://server:85/_vti_bin/lists.asmx are not in the same web application.  Their domains cannot be compatible.

    The scenario I tested is as follows:

    1) Create a DataFormWeb part using SharePoint Designer and put it on web application http://server:80

    Consume data from the Lists.asmx Web Service that resides on Web Application http://server:85

    WSS won’t allow this, if I look in the WSS log file I se entries like this:

    http://server/_vti_bin/webpartpages.asmx and http://server:85/_vti_bin/lists.asmx”>http://server:85/_vti_bin/lists.asmx are not in the same web application.  Their domains cannot be compatible.

    I belive this is logged from SPSite.ValidateDomainCompatibility.

    Can you verify that I’m not supposed to be able to call across Web Applications by design.

    Is there some setting that I can change to allow this?

    Thanks in advance

    /Jonas Nilsson

  2. Tim G. says:

    In WSS v2 the XSL, Parameters, and Data Source were exposed in the Data View properties web part editor directly from the web interface.  

    In the WSS v3 implementation of the Data View (form?) Web Part the Data Source Editor is missing (from the web based web part editor).  This is a real disappointment.  How might a user best edit the Data Source of a Data View Web Part without opening up SPD?

    Thanks for the great post!

  3. Eray,

    Great article – I hope to test it out shortly.  Since you identified yourself as leading the development for the Application Templates for Windows SharePoint Services 3.0, I’m sure you might be interested in my issue below.  I have posted it on several MS/other web sites and received not response…

    To Whom It May Concern:

    Could someone help me or direct me to the right resource to investigate this issue regarding a SharePoint 2003 Application Template…

    While working in the SharePoint 2007 environment and using the Application Template "Budgeting and Tracking Multiple Projects", I was adding "% Complete" to the "Project Milestones" list in order to add a Gantt View.  When trying to ADD a new Milestone, only the default columns appear and "% Complete" does not appear.  This defeats the purpose of a milestone list to show progress.  I have tried this in 2 environments and have concluded this is either a major BUG in the "Project Milestone" list or the "Budgeting and Tracking Multiple Projects" template.  How do issues like these get resolved and/or identified to Microsoft?

    Thank-you for your help,


  4. I have an interesting observation regarding the DataFormWebPart in WSS 3.0.  

    I have been using the web part successfully creating online reports on an issues list.  When I use the "Group By" feature on fields such as Issue Status, I can get a nice total using an xsl function such as count($nodeset) or sub counts with count($nodeset[@Status=’Resolved’]).  However when I "Group by" the field "Created By" I ALWAYS get 0 for count($nodeset).  This makes it impossible to report on activity based on the Author of an Issue.  Is this a bug?  Can anyone suggest a workaround?

    Thanks in advance for any help on this matter!

  5. Christopher Buchholz says:

    Great article, thanks this clears up a lot.

    Iis there any way to create the datasource (pointing to a list) without using the GUID of the datasource? Such as using the name or url. We would like to use the Data View webpart in a template that would point to different lists, and a GUID makes it rather difficult for anyone but developers to set. I found a reference to an undocumented ListName parameter but am having trouble getting it to work.

    Another idea I had was using the CrossList to fake out Sharepoint and somehow get it to look at only one List.

    This is a huge issue for us and no one seems to have the answer.




  6. spdblog says:

    Jonas –  Yes, you’re not supposed to call across Web Applications; unfortunately, there isn’t a setting to change this.  

    Tim G. – You won’t be able to edit the DataSource of a DataFormWebPart without opening SPD, is there a particular reason why you want to avoid opening up SPD? =)  If you’re concerned about customizing a page, you could edit the page in SPD, and then select the option to “Reset to site definition”.

    Rod – The easiest way to get this to show up is:

      1.) Go to list settings –> Advanced Settings and select “allow management of content types

      2.) Click on the content type, and then select “Add from existing site or list columns”

    This behavior is caused by the hidden=”true” setting on the content type definition feature.  

    As for your general question on how these issues get resolved or identified — the Application Templates for WSS are a supported product so you can go through Microsoft’s Support Services: http://www.microsoft.com/services/microsoftservices/srv_support.mspx

    James – For People fields, the SPDataSource returns the entire HTML blob necessary to render as a hyperlink with presence information.  The presence information is actually unique on a per-item basis even if it refers to the same person.  The generic workaround for these sorts of issues is to do the grouping comparisons using the substring function to trim after the person’s name – for example something like this:  substring-before(@Author,’&lt;/A&gt;’).  

    Chris – Yes, in addition to using a ListId, you can also specify a ListName which takes the displayname of a list:  

    <SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="<View></View>" id="Announcements1">


       <WebPartPages:DataFormParameter Name="ListName" ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="Announcements"/>



    Also make sure you have a matching entry in the parameter bindings section:

    <ParameterBinding Name="ListName" Location="None" DefaultValue="Announcements"/>

    It’s also worth noting that we do support ListId fixup in STPs as long as the GUID is wrapped in curly braces:


    There’s a known issue that we’re investigating that SPD doesn’t always spit out curly braces around the GUIDs.  You’ll want to double check that the ListID is correctly wrapped in the SPDataSource’s parameter collection, the DFWP’s parameter bindings, and if you inserted the DFWP into a web part zone, there may also be a ListName attribute on the DataFormWebPart tag.  


    — eray

  7. chris says:

    Thanks I got that working and can change the list it points to in the Parameters section when I select "Modify Shared web part" (obviously changing to a list of the same Content Type).

    One last thing, do you know any way to put in relative URLs? 🙂 It seems that’s the million dollar question. Our client department wants to store a list on a parent site (the template for this site will have the list) and put this in a meeting workspace template so it will automatically show up. Sharepoint does not seem to like using ".."  There must be some template call somewhere I imagine. Otherwise our second choice is creating a web part using a GridView or SPGridView, since I could easily just parse the url in there.


  8. spdblog says:

    Chris – There are a lot of ways to do relative urls:

    Server Relative URL:

        <asp:Parameter Name="WebUrl" DefaultValue="/subweb"/>

    Site Collection Relative:

    This is in context of the site collection root for the opened web.  For example, assume my site collection root is:  http://server/sites/sitecollection/

    This parameter opens this web: http://server/sites/sitecollection/subweb2

        <asp:Parameter Name="WebUrl" DefaultValue="subweb2"/>

    Site Collection Root itself:

        <asp:Parameter Name="WebUrl" DefaultValue="{sitecollectionroot}"/>

    Alternatively you can also use WebID.

        <asp:Parameter Name="WebId" DefaultValue="SomeGuid"/>

    These parameters are compatible with both the ListId and ListName parameters.

    Now about that million dollars….  🙂


    — eray

  9. Jeremy W says:

    Is it possible to insert a list item using the DataFormWebPart from another site in the collection? I tried setting the WebURL parameters, but I get an unspecified error when I view the page and the controls do not preview in SPD. I created the custom form in the correct site, then copied the code to a page in a site above where the list exists. Is there another way? I can get it to work using the data source control and binding to asp.net controls.

  10. DATTARD says:

    Its great that you can specify the ListName as the SelectParameter is SPDataSources. By default SPD created the data sources using the Guid, and these break down when exported to a different server. Using the ListName rather than the Guid ensures that the DataSource still works when it is exported.


  11. BrentN says:

    I’m no developer, let me make that clear 🙂 – But I’m seeing some odd things happening while using SPD and trying to make data form views.

    1. If I use the ListID parameter, which uses the GUID of the list, I continually get errors telling me that the list no longer exists. After clicking OK I’m still able to make the changes I need and the view (sort of) works. These problems go away if I manually change the code to use ListName instead of ListID.

    2. SPD is tossing in a total of 4 separate sets of <WebPartPages:DataFormParameter> which makes for a lot of extra changes when I use ListName in place of ListID. Also, if I change the parameters using the UI (Common Data View Tasks -> Parameters) not all of those DataFormParameter sets is updated and I have to go back and manually fix them.

    3. Sometimes when applying Sorts and Groups the code is generated incorrectly and the connection is broken. Also, some of my colums don’t show up in the list of available fields until I build the expression manually. Yet, those same fields show up fine in other screens, such as "edit columns".

    Any thoughts on this? It seems to me these weird things shouldn’t be happening… They’re really starting to tick me off as well. 🙁

  12. DATTARD says:


    is it possible to create a dynamic datasource by having parameters in the SelectCommand? Example a create a datasource whose CAML is:





    <FieldRef Name=’Title’/>

    <Value Type=’Text’>{ParameterizedTitle}</Value>





    This parameter would then be updated via some SharePoint control. This would allow us to create views dynamically on any SharePoint data, rather than be limited to fixed text in the CAML. I’ve been looking high and low for something like this, but I haven’t come across anything similar yet.

    An example of its usage is would for creating filters on Lookup columns. I have a habit of creating Categorization Lists with just a Title, and then use a Lookup column on the Categorization list. Thus users can add an item to the list and more categorization items are created (or change items etc…)

    A typical example is I create a Status List with the following item Work In Progress, Advanced, Completed. I then use a Lookup to the Status List in Document Libraries or other lists.

    If I had a facility of passing parameters similar to the above, I would not have to create a new view each time that a new item is added to the list but have a single DataSource which takes parameters dynamically from a dropdown.


  13. David Liu says:

    Hi Eray,

    I assume you haven’t got your million dollars yet :p

    From what I have read above, it seems like you can:

    1 – access lists across sites in the same site collection.

    2 – not access lists across web applications because we’re not supposed to do it.

    My question is:

    Can you access lists in the same web application but across different site collections?

    I don’t have a million dollars but I would express much gratification 🙂


  14. Granada says:


    I am also using Budgeting and Tracking Multiple Projects template. We have a requirement to create a subsite for each project and some how rollup all the tasks,  issues for all the projects on the top level site so that the management team can see a real dashboard view of all the projects and related tasks. Each of the project team members can enter their tasks and issues on the project subsite.

    How do I achieve this functionality using Dataview webpart?


  15. Kiran Mantrala says:

    My question:

     I have been using the ‘Job Requisition and Interview Management’ application template in my WSS 3.0 environment. I have been customizing the site according to our needs. But, on the latest development front, we had a requirement where I should be dynamically fill out a Multiline text box with values based on the Job Title i select.

     For (e.g) In the NewForm.aspx for filing a new requisition a user can select the Job Title he wants to post. All the details pertaining to a given Job Title are already stored in a seperate custom list. Now, when the user selects a Job Title, automatically based on the selection made, the Job Description and Work Experience multiline text boxes should be prepopulated with some defined text which is stored in the custom list. All this happen in the same NewForm.aspx page.

     I have been looking out at multiple places since many weeks, but till now could not get a solution. I am posting here to expect some inputs so that i will be able to solve the problem. Any help is really appreciated.


    -Kiran M

  16. Olafur B says:

    Thanks for the much needed tips …

    Where can I find a complete reference of FieldRefs?

    I am having problems with html fields…

    What I want is the html blob but this is what I am getting

    AssignedTo -> 7;#Ólafur Bergsson

    How can I get the links and html blobs to be rendered?

    BTW: I am using a crosslist SPDataSource, selecting my uncompleted tasks…

    Are there any better reference sites than the sparse documentation on MSDN?


    Ólafur Bergsson

  17. Clyde says:


    I have a workflow that is is intended to move a document from a secured document library (source) to a publicly viewable document library (target) when the document’s status changed to ‘published’. This works fine the first time but fails the second time as the COPY LIST ITEM item fails because the document is already in the target document library, which is no good as I want the document overwritten with the updated version.

    So I added a delete action to the workflow. However the workflow fails when run for a new document that is set to published. This is because it cannot find the document in the target library to delete.

    How can I make the absence of the document in the target library non-fatal for the workflow or alternatively how can the COPY LIST ITEM be made to overwrite?

    Apologies if this is the wrong place to post!

  18. PatrickMYC says:


    I am trying to create a DataForm in a site while using a Data Source form a different site(both subwebs) but only the DataView is available. The DataForm option is only available when the Data Source in in the same site. The Data Sources I am using are basic Sharepoint lists.

    Is it not possible to use a DatForm for editing a Data source across subwebs?

    I must be missing the obvious!


  19. martinsodoma@hotmail.com says:


    1) It would be nice to add designer support for FieldRef attribute LookupId="TRUE". You can use it when you want to display Order and all OrderItems (OrderItem has lookup column to Order).

    2) Please, fix bug in ddwrt:URLLookup described here:


    Is it possible to insert old DataViewWebpart? It could be workaround for this bug.



  20. Eli says:

    hi, DATTARD, did you find a way to solve your problem? i have a smiliar situation,

    im building a sales portal with informationa bour clients and different projects, i have a main list where i have all my clients information, and for each item in that list i create a site with the clients name.

    Whay im trying to do, is that the clients site main page displays the information about the client. im trying to use a dataview, but im stucked in sending the site name or any value as a parameter so the dataview will know what information to show. (query string is not an option, since it can be modified by the user, and im not sure how to add the query string to the menus and navigation links)

    Whay i would love is if i could use a field in the page or the site name as a parameter to the dataview.

    is it possible?

  21. Andy says:

    This article helped me a lot when trying to filter DataSources dependend on a query string variable (good hint with the curly braces!). Thank you for that. Now I would like to use QueryStringParameters in other parts of the aspx-File. By accessing the parameters I could easily hide forms with xsl (xsl:when). But I can’t figure out how to use the same parameters in XSL-Tags. How can I access query string variables there? Is it possible at all?

  22. Marwan Tarek says:

    thanks for this great information but i think the dataview need more detailed documentation for its functionality with samples.

    because it is powerful and few number of devs know how to use it

  23. So I have been on the road for quite a while and hopefully will now finally get some time to start getting

  24. martinsodoma@hotmail.com says:


    I’ve some problem with Custom "New Form" when you have list with multiple content types.

    1) In SPD you choose ContentType for New Form. It works fine, it generates appropriate field controls.

    2) If you choose non default ContentType, save item is always saved as default ContentType.

    A) I’ve tried to add ContentType field to form. Field is rendered correctly but the selected value is not saved.

    <SharePoint:FormField runat="server" id="ff8{$Pos}" ControlMode="New" FieldName="ContentType" __designer:bind="{ddwrt:DataBind(‘i’,concat(‘ff8′,$Pos),’Value’,’ValueChanged’,’ID’,ddwrt:EscapeDelims(string(@ID)),’@ContentType’)}"/>

    B) I’ve tried to add ContentTypeId field to form. It doesn’t work.

    C) I’ve tried to add Insert Parameter <WebPartPages:DataFormParameter Name="ContentTypeId" ParameterKey="ContentTypeId" PropertyName="ParameterValues" DefaultValue="…" />. It doesn’t help.

    Where is the problem?



  25. How do I create a view that rolls up data from across my site collection?

  26. James Pritchett says:

    I’m researching an issue for my sharepoint developer in charge of our ticketing system.  He set up a series of sites for each of our clients.  Each client’s site has a tasks list.  There are 8 developers all of whom have tasks assigned to them in various sites.  He has so far been unable to produce for us a page that shows all the tasks across all sites.  Obviously, It’s very difficult for us to have to look at each customer’s site each day to see what items are assigned to us.  

    I have to assume that there’s something that we’re missing.  Is there an example somewhere of a rollup-type list page that we can modify to fit our environment?

  27. Martin says:

    I have created a data view on a page on the main site. This calls info from a list on the subsite. Once the user clicks on the link it goes to the displayform item except it is missing the return Source string.

    Does anyone know where this appended and how to enable this so that when the user clicks close they return to the page on the main site rather than the all items page.

  28. Andy Stout says:

    I was able to roll up all task lists from my site collection but I wanted to add sorting a filtering to the list.  I enabled sorting and filtering in the DataFormWebPart using SharePoint Designer but when I view the page and click on a column header, I get the following error within the sorting/filtering menu:

    "This column type cannot be filtered"

    This rollup method blows the content query web part method out of the water but I would still like to be able to use the sorting and filtering functions that the DataFormWebPart control offers.

  29. mwherman2000 says:

    Which of the WSS 3.0 templates are good examples of ListofLists and Crosslist data sources?

  30. MichaelB says:

    I tried following your CrossList example. I have a site and a subsite that have identical document libraries which use an InfoPath form as their document template.

    In List mode, I the Data View web part displays the data just fine. However, as soon as I change it to CrossList and change the Select Comand, I get no rows returned.

    Any advice on debugging this?

    Is there a newsgroup (Partner-only or public) that is monitored more frequently that would be a good place to seek help with this?

  31. Kumar says:


    I have a dataviewwebpart with filtering, sorting and grouping enabled for a list. The list has some category columns that are used in filter dropdowns. It seems the filter values in the dropdowns are populated based on the number of records returned in the list. as a consequence some columns like category have repeating values in the them,i.e duplicate entries. It would be nice if the dropdown values like category have only unique values in them. So given the above scenario how should i  modify the xslt for filter columns to achieve the above objective? Is it possible?


    List records returned in the dataviewwebpart:

    Field1                  Field2                  Category


    Test1                   value1                  Category1

    Test2                   value2                  category1

    Test3                   value3                  category1

    Test4                   value4                  category2

    Test5                   value5                  category2

    Filter values that are displayed for category at present:    

    Category dropdown   ->  Category1





    But what is required in the category dropdown:

    Category dropdown ->  Category1


    If anyone has a solution please help me.

    Thank you so much.

  32. Grayden says:

    I’m using the DataView web part (http://schemas.microsoft.com/WebParts/v2/DataView), with a Database connection to Sql, calling a stored procedure, with no parameters.

    When I turn on "Enable sorting and filtering on column headers (basic table layout only)", the setting is not working. The custom query renders the sorting/filtering drop down links on the column headings, yet neither works.

    I’ve done a view source and the fields are set correctly, eg:

    ‘dvt_sortfield={FirstName};dvt_sortdir={‘ + ‘descending’ + ‘}’);"  // where FirstName is one of my stored proc field names

    Am I missing something???

    There is no mention of this setting when using SharePoint Designer help – only "Sort and Group", which are not set in my example, and would not provide the ability for the user to click on column headings.


  33. David says:

    Is there a way to update the page title of an aspx page in SharePoint based on a value in the Data Form Web Part. I have a Data Form Web Part which shows a single item from a list based on the ID passed on the query string. I would like to use the title field of this list item to set the page title for the current aspx page. Is there a way to pass values from the Data Form Web Part to the page?

  34. jonathanB says:

    The fix for data views to access lists across sites seems top work EXCEPT that

     <asp:Parameter Name="WebUrl" DefaultValue="{sitecollectionroot}"/>

    only works for subsites of the root and NOT subsites of the subsites.

    The variant

       <asp:Parameter Name="WebId" DefaultValue="SomeGuid"/>

    will clearly work but is not maintainable code due to the coded guid

    Any advice? None of this seems documented on msdn? Are they "secret" parameters?

  35. Prashant Khadke says:

    Hi all,

    I am new to the sharepoint 2007 and requried help on SPDataSource.

    My requriments

    1 )Access list data from 2 diffent sit collection and show it on the page.

        How it can be done?

    2) I am not able to use CrossList as a DataSourceMode to access the list from same site collection.

       can any one provied sample on CrossList ?

      (I have achive this by creating linking Source).

    Please help me.


  36. mekrish says:

    Hi all,

    I am trying to bind the "Type" field from teh document library to my custom SPGridview. I am using SPDatasource in list mode. Can anyone suggest me how to display the corresponding image field according to the type of document.

    I want to mimic the same behavior as MOSS doucument library. I was able to bind all other field but when i bind the Type field i only get  1 and 0.


  37. dremillard says:

    I’m trying to sort and group people in the DVWP and it doesn’t seem to work.  It’s because the people (or is it person?) data type contains all of the chrome for rendering presense, etc. and so sorting an grouping don’t work as expected.  This is such a common behavior that people would want to do that I have to believe that someone has already come up with a suitable workaround.  

    I saw that you said to trim the extraneous HTML, and I did that, but it didn’t solve the sorting and grouping problem … BTW, filtering is also broken for person data types.  

    Is there a workaround, or something that I’m missing?  Thanks, Dave.

  38. Matthew says:

    Do you have an example using the asp:SqlDataSource against a stored proc with parameters? This worked in 2003 and I cannot get it to work in 2007. SPD does not save the parameter values I enter.

  39. AliV says:

    Hi all

    Thabk you for the great article.

    I am using a DataFormWebPart, and I put filter on ut using query. My web part perform filtering on three fields:Title,DocNo and ORG by "And" Connective between them. I pass the user’s entries to the <Query></Query> using three parameters.But when one of the entries is empty the result data is nothing.I tried to use <Switch> in <View> element but it seems that <Switch> is not allowed in <View>.

    What do you suggest I should do? (I mean some way except usimg object model and no to hamdle this problem programmaticaly)

    Thanks alot.

  40. Chad says:


    Have you ever figured out a solution to this? I am trying to achieve the same thing but having no luck with it.

    Also the filter dropdowns are screwy too


  41. Tommi Kovalainen says:

    Dataview webpart is a great tool, but it has one major flaw. Aggregating data from the whole site collection is a basic function in CQWP, but in dataview you have to write to code to do the same. Why can’t there just be equal settings like in CQWP?

  42. dremillard says:


    No, I never figured it out … or found any reference to a solution.  It would be nice to get a reply.  Eray, are you still there?  


  43. Murad says:

    Is there a solution for the Filter drop down not showing unique enteries?

    I have a multivalue lookup field in a dataview and want to send the information to another dataview which has the lookup list.  I want to filter the lookup list based on the value coming from the multivalue column?


  44. Shawn says:

    Kumar and Murad,

    I was having the same issue where the filter would apply to the exact string of the column.  So if you had a multi select column with say values a, b, c filtering by ‘a’ would filter out this item.  The xsl variable dvt_filterval is what contains the value.  By making some changes to the assignments of dvt_FilteredRowsText, dvt_FilteredRows, and dvt_FilteredRowsAttr I was able to make it so that if the column contained dvt_filterval within the column it would not filter it out.  Here are the changes:

    <xsl:variable name="dvt_FilteredRowsText" select="$Rows[contains(.,$dvt_filterval) or ($dvt_filtertype=’date’ and substring-before($dvt_filterval,’T’) = substring-before(.,’T’))]" />

    <xsl:variable name="dvt_FilteredRows" select="$Rows[contains(normalize-space(*[name()=$dvt_filterfield]), $dvt_filterval) or ($dvt_filtertype=’date’ and substring-before($dvt_filterval,’T’) = substring-before(normalize-space(*[name()=$dvt_filterfield]),’T’))]" />

    <xsl:variable name="dvt_FilteredRowsAttr" select="$Rows[contains(normalize-space(@*[name()=$dvt_FieldNameNoAtSign]), $dvt_filterval) or ($dvt_filtertype=’date’ and substring-before($dvt_filterval,’T’) = substring-before(normalize-space(@*[name()=$dvt_FieldNameNoAtSign]),’T’))]" />

  45. Shawn says:

    To make it so that filter fields populated with unique values it took quite a bit of custom xslt.  The multi select columns I used were Lookup types that used existing lists.  So to be able to populate those values into a drop down you first have to add them in as data sources so that they are available in the xml.  Then to make sure they don’t show up in the DataFormWebPart display you have to filter them out of the Rows variable.  My list’s name was Products so the Rows assignment looks as follows:

    <xsl:variable name="Rows" select="/dsQueryResponse/Rows[@source !=’Products’]/Row" />

    Then create a new variable with the Rows you want visable in the drop down

    <xsl:variable name="Products" select="/dsQueryResponse/Rows[@source = ‘Products’]/Row" />

    The template dvt.filterfield is what populates the filter fields so you will have to pass the new variable to this filter instead of Rows.  You’ll also have to custimize which field in the list the drop down is populating on.  If this field is named different then the fields in the lists being displayed in the DataFormWebPart you want the filter to populate on you’ll have to write a custom filterfield template which is what I did.  My custom filter field has an extra field in it called targetfieldname so that it knows what field to apply the filter to since it is different then field populating the drop down.  Title is the field being used to populate the drop down in my case.  Here is the call to the custom template:

    <xsl:call-template name="dvt.customfilterfield">

        <xsl:with-param name="fieldname">@Title</xsl:with-param>

        <xsl:with-param name="fieldtitle">Products</xsl:with-param>

        <xsl:with-param name="targetfieldname">@Products</xsl:with-param>

        <xsl:with-param name="Rows" select="$Products" />

        <xsl:with-param name="fieldtype">text</xsl:with-param>


    And here is the template being called:

    <xsl:template name="dvt.customfilterfield">

        <xsl:param name="fieldname" />

        <xsl:param name="fieldtitle" />

        <xsl:param name="targetfieldname" />

        <xsl:param name="Rows" />

        <xsl:param name="fieldtype" />                    

        <xsl:variable name="dvt_FieldNameNoAtSign" select="substring-after($fieldname, ‘@’)" />                    

        <xsl:variable name="filtertype">

             <xsl:if test="starts-with($fieldtype,’date’)">date</xsl:if>


        <xsl:variable name="sorttype">


            <xsl:when test="starts-with($fieldtype,’number’)">number</xsl:when>




                        <xsl:variable name="clientText">&apos; + this.options[this.selectedIndex].value + &apos;</xsl:variable>

                        <xsl:if test="not(contains($fieldname, ‘/’)) and not(contains($fieldname, ‘[‘))" ddwrt:cf_ignore="1">

                         <xsl:value-of select="$fieldtitle" />

                          <xsl:text disable-output-escaping="yes">:&lt;br&gt;</xsl:text>

                         <select name="{$fieldtitle}_filterval">

                           <xsl:attribute name="onchange">

                             javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat(‘NotUTF8;dvt_filterfield={@’,$fieldtitle,’};dvt_filtertype={‘,$filtertype,’};dvt_adhocmode={false()};dvt_filterval={‘,$clientText,’}’))" />;


                           <option value="##dvt_empty##">

                             <xsl:if test="$dvt_filterfield=$fieldname and $dvt_filterval=”">

                               <xsl:attribute name="selected">true</xsl:attribute>




                           <option value="##dvt_all##">


                               <xsl:when test="not($dvt_filterfield)">

                                  <xsl:attribute name="selected">true</xsl:attribute>


                               <xsl:when test="$dvt_filterfield!=$fieldname">

                                  <xsl:attribute name="selected">true</xsl:attribute>





                           <xsl:value-of select="ddwrt:NameChanged(”,1)" />


                              <xsl:when test="starts-with($fieldname, ‘@’)">

                                <xsl:variable name="dvt_Rows">

                                  <xsl:for-each select="$Rows">

                                    <xsl:sort select="@*[name()=$fieldname]" order="ascending" data-type="{$sorttype}" />

                                   <xsl:copy-of select="." />



                                <xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(@*[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::*[1]/@*[name()=$dvt_FieldNameNoAtSign])]/@*[name()=$dvt_FieldNameNoAtSign]">

                                  <xsl:sort data-type="{$sorttype}" />

                                  <xsl:call-template name="dvt.filteroption">

                                    <xsl:with-param name="name" select="$targetfieldname" />

                                    <xsl:with-param name="value" select="." />

                                    <xsl:with-param name="type" select="$fieldtype" />




                              <xsl:when test="$fieldname = ‘.’">

                                <xsl:variable name="dvt_Rows">

                                  <xsl:for-each select="$Rows">

                                    <xsl:sort select="." order="ascending" data-type="{$sorttype}" />

                                   <xsl:copy-of select="." />



                                <xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(.=preceding-sibling::*[1])]">

                                  <xsl:sort data-type="{$sorttype}" />

                                  <xsl:call-template name="dvt.filteroption">

                                    <xsl:with-param name="name" select="$targetfieldname" />

                                    <xsl:with-param name="value" select="." />

                                    <xsl:with-param name="type" select="$fieldtype" />





                                <xsl:variable name="dvt_Rows">

                                  <xsl:for-each select="$Rows">

                                    <xsl:sort select="*[name()=$fieldname]" order="ascending" data-type="{$sorttype}" />

                                   <xsl:copy-of select="." />



                                <xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(*[name()=$fieldname]=preceding-sibling::*[1]/*[name()=$fieldname])]/*[name()=$fieldname]">

                                  <xsl:sort data-type="{$sorttype}" />

                                  <xsl:call-template name="dvt.filteroption">

                                    <xsl:with-param name="name" select="$targetfieldname" />

                                    <xsl:with-param name="value" select="." />

                                    <xsl:with-param name="type" select="$fieldtype" />





                           <xsl:value-of select="ddwrt:NameChanged(”,1)" />




    Hope this helps

  46. Roni says:

    WebURL Parameter and Drop Down Filter Problem:

    I’m using a DataFormWebPart (with sorting and filtering enabled) to display data from a custom list. Without the WebURL Parameter everything works fine, but the usage of the web part is limited to the web containing the custom list.

    To use it in a parent web of the custom list I tried to work with the WebURL parameter. But as soon as I use this parameter the drop down filters on the column headers won’t work. The drop down opens and with some delay the following message appears:

    "This column type cannot be filtered"

    Am I missing something? Is this by design or is it a bug?

    Thanks for any help,


  47. spdblog says:

    Hi Roni,

    There are some issues with gettng the schema when you use the WebURL property. Instead of doing that route, can you try using manage catalog?

    Open the parent site in SPD

    Click on Task Panes > Data Source Library

    Click on Connect to other library (this is from memory, so that may be the wrong string)

    Type in the URl of the child site with the custom list. Click OK

    Expand that library

    Insert a view of the Custom List

    Data View..Change Layout :: General tab

    Enable sort/filter on column headers. Click OK

    Save the page

  48. Naeem says:

    i need to develop a dynamic selectcommand in sharepoint designet is it posiblle?

    actually my senario is that i want to do some filtering on the bases of query string variables

    Note: there are more then one variable and i want when they are not null then some filter apply on my dataview web part

    Please help me out.

  49. Roni says:

    Thanks spdblog for your quick answer.

    Your description is more or less exactly what I did. With these steps SPD will automatically insert the WebURL Parameter which will cause the problems with the drop down filters.

  50. spdblog says:


    Ah. Yes, sorry for my previous post. I should have performed the steps myself, but at the time I didn’t have SPD 2007 installed (I’m head’s down on the next version). I installed it overnight and I see what you are saying.

    I spoke to the developer about this, and while it feels like a bug, it’s actually ‘by design’. Of course, that didn’t stop me from logging the issue so that we might be able to get a minor design change here in a service pack (though I don’t want to get your hopes up), or possibly in the next version.

    The issue is that we can’t get the schema information from the subsite based on our query at the AJAX layer. Our code defaults to ‘cannot be filtered’ rather than to ‘can be filtered’ when we don’t have schema information.

    Unfortunately, the work around is to use our adhoc toolbar rather than the AJAX mechanism. To do that you check the box Data View Properties General tab that says "Show toolbar with options for:" and check the Filter box.

    Sorry I don’t have better news for you on this one…

    -John (Test Lead, SPD)

  51. Roni says:

    Thanks John. I tried to follow the mechanism behind (post back, java script, …) and assumed something like that. The toolbar isn’t that nice but we will see.


  52. Craig says:

    Does the SelectCommand CAML work when using ListName (list display name) instead of ListID (list GUID)?  I can’t seem to get a simple filter (WHERE) to work.  It throws the error:  "The server returned a non-specific error when trying to get data from the data source.  Check the format and content of your query and try again.  If the problem persists, contact the server administrator."

  53. vinay Gandhi says:


    I need to create a view where i could filter items based on person field (multiple selection).

    I tried this in SP designer, but i can’t create dataview with filter on this field.

    Please help.



  54. Jared says:

    I would GREATLY appreciate any tips on how to do a Calendar rollup much like this Data View rollup… I’m on day seven and still having massive difficulties in both research and attempts to do so.  The logic is, if a Calendar view can be created for any list (with included date fields), then why can’t a MASTER Calendar view be created with its source as being recursive of all the other lists?

  55. Allen says:

    Thank for your post.

    I would like to know if there is any possibility to sort data list  by group count. I mean group by some column and get count of each group, then sort by the count of the group.


    Group A  (1)


    Group B  (2)



    Group C (3)




    Any tips, I greately appreciate.

  56. Jonathan says:

    I have followed this and other posts to get a crosslist recursive dataview working.  Thank you *Very* much for this post!

    However I m seeing some strange behavior that I hope you can provide some insight into.

    I have a site, with two subsites.   Each of these subsites has a task likst on it.

    If I create a task rollup dataview in designer.

    datasource defined as:

    <SharePoint:SPDataSource runat="server" DataSourceMode="CrossList" UseInternalName="true" selectcommand="&lt;Webs Scope=’Recursive’&gt;&lt;/Webs&gt;   &lt;View&gt;&lt;ViewFields&gt;&lt;FieldRef Name=’ID’/&gt;&lt;FieldRef Name=’AssignedTo’/&gt;&lt;FieldRef Name=’FileDirRef’/&gt;&lt;FieldRef Name=’ContentType’/&gt;&lt;FieldRef Name=’Title’/&gt;&lt;/ViewFields&gt;&lt;/View&gt;" id="Tasks1"></SharePoint:SPDataSource>

    Information is displayed from my subsite’s lists.

    In designer I edit the dataview and select the "common dataview tasks" | "Chanmge layout" | general and check "enable sorting and filtering on column headers (basic table layout only"

    Back in IE when I click on one of the column headers, or select a sort order i get the  error listed below.

    Server Error in ‘/’ Application.


    There are multiple root elements. Line 1, position 37.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Xml.XmlException: There are multiple root elements. Line 1, position 37.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

    Stack Trace:

    [XmlException: There are multiple root elements. Line 1, position 37.]

      System.Xml.XmlTextReaderImpl.Throw(Exception e) +90

      System.Xml.XmlTextReaderImpl.Throw(String res, String arg) +127

      System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res) +35

      System.Xml.XmlTextReaderImpl.ParseDocumentContent() +1954136

      System.Xml.XmlTextReaderImpl.Read() +41

      System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) +557

      System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +50

      System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +162

      System.Xml.XmlDocument.Load(XmlReader reader) +96

      System.Xml.XmlDocument.LoadXml(String xml) +197

      Microsoft.SharePoint.WebPartPages.DataFormWebPart.SetAdHocSortClause(String sortField, String sortDir) +349

      Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform() +1719

      Microsoft.SharePoint.WebPartPages.DataFormWebPart.PerformSelect() +62

      Microsoft.SharePoint.WebPartPages.DataFormWebPart.DataBind() +92

      Microsoft.SharePoint.WebPartPages.DataFormWebPart.EnsureDataBound() +44

      Microsoft.SharePoint.WebPartPages.DataFormWebPart.CreateChildControls() +1275

      System.Web.UI.Control.EnsureChildControls() +87

      Microsoft.SharePoint.WebPartPages.DataFormWebPart.RaisePostBackEvent(String eventArgument) +7354

      System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11

      System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177

      System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

  57. Jonathan says:

    The issue is the <webs></webs> tag needs to be *inside* the <view></View> tags.  That does the trick

  58. denap says:

    hmmm.  Just finding this thread.  

    I’m trying to ‘link’ related docs in some maintable way.  Each document has an ID.

    We want to file requirements in one folder, specs in another, and change requests in a third etc.  Short of adding a cross-ref field to each item with all of the other document ids in it (which is subject to human error)  could we use this cross-list method of creating a ‘roll-up’ DL that related docs together?  

    We could do this with search, but again, this would be subject to fishing through a string field for a value someone easily could ruin.  Anyone have experience or advice on how to accomplish this without rekeying each related doc in each docs properties?


  59. nirav says:

    Firing the CrossList Query returns result like






           <Title>Item 1</Title>






           <Title>Item 1</Title>



    Its possible to print Item Title using @Title

    as <xsl:value-of select="@Title"/>

    I also want to show from which site that item belongs to

    If I try <xsl:value-of select="@WebID"/> It displays that ugly GUID on screen.

    My question is How to show Site name , not its WebID ( GUID )

    For E.g I want to show

    |Title              | Site


    |Item 1           | Finance

    |Item 2           | Marketing

    Also how can we generate URL of that site using GUID ? so I can give hyperlink too.

  60. bhargav says:

    how to save DataFormWebPart by savewebpart method of sharepoint webservices..  from "_vti_bin/WebPartPages.asmx" ?

  61. How to query cross-site lists in DataFormWebPart – Part 1. Build your own data source for DataFormWebPart

  62. Anne says:

    Is there a way to display items in the DataFormWebPart from a list in a different site (also separate web app)?

    If not, is there an alternative web part that can be used to achieve this?

  63. Objectfactory says:

    The SPDatasource is easy to use and works fine all the time.

    BUT it doesn’t return the internal IDs of LookUpField entries. It just returns the titles of the LookUpField entries. Why? This is not clear to me.

    To get the internal IDs of assigned entries in a LookUpField I have to use a SOAPDatasource instead. This returns the internal IDs.

    BUT the SOAPDatasource doesn’t work all the time in my environment. We use HTTPS company wide. Sometimes I have to use




    to get it work. Sometimes nothing works. I think it’s a configuration problem of our web servers. But I do not understand why the tool u2u CAML builder works fine and all the SPDatasources too.

    I’m not able to work in this way.

  64. Doug says:

    I wanted to use a template from Application Templates for Windows SharePoint Services 3.0 but I am not the main site admin. Actually I am the admin of lower site (or subsite). Mainly I wanted to learn how to come up with a view like the one displayed for a project from the project list in the IT template. I would hope that in the future we do not have o depend on the "higher admin" to enable nice features on the "lower sites". In the meant time anyway I can learn to create that view (It shows the project list then the related tasks and milestones and issuess).

    Thank you.

  65. Tamas says:

    I use Countent Query Webpart to gather the projecttask from my other subsites. I’m gouping them by the sites.

    In the result list I need to print the item count for each group, like:

    Group1 (2)



    Group2 (1)


    Can anybody help?


  66. Nestor C. says:


    I have successfully built a dataviewwebpart with filtering, sorting and grouping for a list to show total counts of a particular status. The list has people’s names, the department they work in, and their status with regards to present or absent.  In the dataview I then display for each department the total amount of people either present or absent.  The resultant table looks something like this:

    Department          Present          Absent

    HR                       4                   1

    Sales                    6                   2

    Shipping              10                 1

    My problem is when there is no one of a particular status, rather than showing a zero in the Status count, it shows nothing, like this:

    Department          Present          Absent

    HR                       4                   1

    Sales                    6                   2

    Shipping              10                

    My question is how to show the zero when there is an empty count for that department row?



  67. Nitu says:

    Hi Nestor,

    I am trying to achieve the same kind of report in my main site, where i am pulling data from the lists in subsites. can you please tell me how to do that. I would really appreciate any help. You can email me at nituagg@yahoo.com, if you prefer… Thanks…

  68. Nestor C. says:

    Hi Nitu,

    (I’m posting here just because other people might have the same question.)

    The way I did it was to create three list DataViews side-by-side, only showing the Department or the particular status field.  I then Applied a status filter and under Sorting and Grouping selected show Footer, but under Advanced grouping I selected to "Hide Details".  This prevents all the people’s names from showing up.  Hope this helps.


  69. David says:

    I am having the same problem as stated above by Grayden on August 31, 2007 1:29 AM.

    Pretty simple stuff here.  I have a DFWP bound to a SPSqlDataSource where SelectCommandType="StoredProcedure".  The stored procedure is very simple, taking no arguments, returning a couple columns from a single table.

    The headers, when clicked perform a postback, but no sorting occurs.

    Running similar tests, if I use sql for the selectcommand, even with parameters, sorting works fine.

    I’ve seen a few posts on this in various places, but no solution.  Any ideas?

  70. Steve says:

    Nirav, did you find a solution to your issue yet?  I have the same question – how do you display the name of the site a list item is from in a crosslist query?

  71. Shaun says:


    I have a list in which i stored some report types and the urls for reports. i have created a dataview in which i retrieved all the information from one datasource(Custom List) now i want to fetch the url of that pirticular Report type in the list.

    can it be possible through crosslist?



  72. Muthu says:

    Hi Shawn

    the code for removing duplicate values in Filter fields in dataview webpart is not working. please give me anyother solution



  73. BS says:


    I have a data view webpart in page layout configured to a document library to show a flash item. All the subsites are also showing the same flash item. How to pass the parameters as per the site?

    Please help me to figure out the issue.

  74. Dear All,

    Thanks for the comments,

    i have one question about the dataview parameters…

    can i pass a dynamic value for the parameter??

    ex.: i have this line…

    <WebPartPages:DataFormParameter Name=”ListName” ParameterKey=”ListName” PropertyName=”ParameterValues” DefaultValue=”News”/>

    i need to change the DefaultValue according to some criteria, and i have the value returned from a javascript function!!!

    can i pass the returned value??

    <WebPartPages:DataFormParameter Name=”ListName” ParameterKey=”ListName” PropertyName=”ParameterValues” DefaultValue=”MyJavaScriptFunction()”/?????

  75. SPDataSource – a refresher So last time in part 1 of this 2-part series, we saw how SPDataSource is a

  76. Jester says:

    I just can’t get this to work. If I follow this example through when I save the page the data source tab that show the rows increases the row count but only the following fields appear : ListId, WebId and Id.

    Is this because I have not specified the ServerTemplate attriibute ? Even adding the server template does not fix it. This is the xml snippet I’m using:-


    <SharePoint:SPDataSource runat="server" DataSourceMode="CrossList" UseInternalName="true" selectcommand="<Webs Scope=’Recursive’></Webs>&lt;View&gt;&lt;/View&gt;" id="Announcements1"><SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="65DA41BF-7F20-4371-9E72-C96DE3A54C3E"/></SelectParameters><DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="65DA41BF-7F20-4371-9E72-C96DE3A54C3E"/></DeleteParameters><UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="65DA41BF-7F20-4371-9E72-C96DE3A54C3E"/></UpdateParameters><InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="65DA41BF-7F20-4371-9E72-C96DE3A54C3E"/></InsertParameters></SharePoint:SPDataSource>



      <ParameterBinding Name="ListID" Location="None" DefaultValue="65DA41BF-7F20-4371-9E72-C96DE3A54C3E"/>

      <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>

      <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>

      <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>


    <datafields>@ID,ID;@ContentType,Content Type;@Title,Title;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified By;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;@Body,Body;@Expires,Expires;</datafields>

    Hopefully you can shed some light.



  77. Ketaanh Shah says:

    Hi Eray thanks for a wonderful post, the last section of your post "Create a view that shows all announcements in the site collection" has few things to take care in SPD i.e. in the SELECTCOMMAND we need to add the tags as you have explained in earlier section of the blog. i.e. the SELECT COMMAND would look like:

    SelectCommand="<Webs Scope=’Recursive’></Webs> <Lists ServerTemplate=’104′ BaseType=’0′></Lists> <View> <ViewFields> <FieldRef Name=’ID’/> <FieldRef Name=’ContentType’/>

    <FieldRef Name=’Title’/> </ViewFields> </View>"

    And then it will render the data from all announcements lists in the site collection. Your post is really very helpful and I would like to add the above comment so that other users will get it working.

  78. SPDataSource – a refresher So last time in part 1 of this 2-part series, we saw how SPDataSource is a

  79. Kosher says:

    I have the same issue as smartin August 2 2007  sheesh, the neglect you guys… the neglect:

    Smartin said.  SOMEONE WAKE THESE GUYS UP!!!!!! B0rk3n as hell.


    I’ve some problem with Custom "New Form" when you have list with multiple content types.

    1) In SPD you choose ContentType for New Form. It works fine, it generates appropriate field controls.

    2) If you choose non default ContentType, save item is always saved as default ContentType.

    A) I’ve tried to add ContentType field to form. Field is rendered correctly but the selected value is not saved.

    <SharePoint:FormField runat="server" id="ff8{$Pos}" ControlMode="New" FieldName="ContentType" __designer:bind="{ddwrt:DataBind(‘i’,concat(‘ff8′,$Pos),’Value’,’ValueChanged’,’ID’,ddwrt:EscapeDelims(string(@ID)),’@ContentType’)}"/>

    B) I’ve tried to add ContentTypeId field to form. It doesn’t work.

    C) I’ve tried to add Insert Parameter <WebPartPages:DataFormParameter Name="ContentTypeId" ParameterKey="ContentTypeId" PropertyName="ParameterValues" DefaultValue="…" />. It doesn’t help.

    Where is the problem?



    August 2, 2007 11:15 AM

  80. Kosher says:

    ^^^^^^^^^^^^^^  A YEAR LATER ^^^^^^^^^^^^    The guys is still wondering how to resolve his issue.  WOW.

  81. One of the most powerful new OM calls in Windows SharePoint Services v3 is the GetSiteData method on the SPWeb object. This method makes it possible to query for items across multiple lists in multiple Web sites in the same site collection. This is most

  82. Santhosh says:

    Nirav, did you find a solution to your issue yet?  I have the same question – how do you display the name of the site a list item is from in a crosslist query?

    kindly send the solution to my mail id mmsanthosh@hotmail.com….

  83. Santhosh says:

    A Data View Web Part (DVWP) that displays a dropdown can be a useful tool to drive navigation.  See my previous post about showing content archives (Displaying an Archive for a SharePoint List) as an example.

    If you have a decent number of items in the list you are using, you will likely end up with duplicates in your dropdown, which isn’t really what you want.  Here’s the trick to remove the duplicates.

    When you add your DVWP, add your column for the dropdown, and set your DVWP layout to a dropdown view type, you will get a chunk of code like the following:

    <xsl:template name="dvt_1.rowview">


       <xsl:attribute name="value">

         <xsl:value-of select="@Your_x0020_Column" />


       <xsl:value-of select="@Your_x0020_Column" />


    </xsl:template>Find this code, and change it as follows:

    <xsl:template name="dvt_1.rowview">

       <xsl:variable name="NewGroup" select="ddwrt:NameChanged(string(@Your_x0020_Column), 0)" />

       <xsl:if test="string-length($NewGroup)">


               <xsl:attribute name="value">

                   <xsl:value-of select="@Your_x0020_Column" />


               <xsl:value-of select="@Your_x0020_Column" />



    </xsl:template>The ddwrt:NameChanged function will return a value only when the value of the column has changed since the last new value.

    Next up: How to make something happen when the user selects a value from the dropdown.

  84. PJC says:

    I am attempting to share list data featuring a calculated column via a Data View Web Part (DVWP).  The DVWP was created on a different site by accessing the list data via a shared library connection.  Upon inserting the desired fields as a Mulitiple Item List, I see all of the data except for the calculated column data.  Oddly enough, if I insert a formula into the blank calculated field column that simply references the pertinent field name, the data is revealed.  Why wouldn’t it show this data immediately after inserting the fields?



  85. PJC says:

    Potentially related to the aforementioned DVWP data display issue, I also attempted to replicate the Cross List rollup solution cited by Eray in his initial posting.  While I was able to generate a DVWP featuring a number of rows corresponding to the number of sites with the Announcements web part, all of the fields in the DVWP were blank.  In light of my previous post, could this be due to a security or configuration setting?  If so, where should I be looking to resolve this issue?

    Thank you!


  86. Bobby Vastakis says:

    Hi all,

    I have a question pertaining to a data view.  I am inserting a single item form from a data view that gives users the ability to insert, edit, and deletea a record.  The database connection is on SQL Server 2000.  I was curious if Sharepoint has a built in function that allows me to insert a modified by and modified date columns to each record.  I want to track these fields for every change that is made to the data in the tables.

    Is this only a function of a workflow? And is a workflow something I should be doing to allow users to edit/update/insert data into this table.  

    Also, when an insert/update/delete command is used in a single item form, is there a way to show a confirmation window saying that a record has been updated/deleted/inserted successfully.

    Thanks in advance for the help.


  87. I got the Annnouncement lists to rollup, but I cannot seem to get the same behavoir with events lists.

    My Announcements Data source

    <SharePoint:SPDataSource runat="server" DataSourceMode="CrossList" UseInternalName="true"

    selectcommand="<Webs Scope=’Recursive’></Webs><Lists ServerTemplate=’104′ BaseType=’0′></Lists>&lt;View&gt;…/View&gt;" id="announcements1">

    <SelectParameters><asp:Parameter Name="ListID" DefaultValue="AACC41A6-B555-41CA-8D94-7A5F334B8CE9"/></SelectParameters>

    <DeleteParameters><asp:Parameter Name="ListID" DefaultValue="AACC41A6-B555-41CA-8D94-7A5F334B8CE9"/></DeleteParameters>

    <UpdateParameters><asp:Parameter Name="ListID" DefaultValue="AACC41A6-B555-41CA-8D94-7A5F334B8CE9"/></UpdateParameters>

    <InsertParameters><asp:Parameter Name="ListID" DefaultValue="AACC41A6-B555-41CA-8D94-7A5F334B8CE9"/></InsertParameters>


    My Events Code

    <SharePoint:SPDataSource runat="server" DataSourceMode="CrossList" UseInternalName="true"

    selectcommand="<Webs Scope=’Recursive’></Webs><Lists ServerTemplate=’106′ BaseType=’0′></Lists>&lt;View&gt;&lt;/View&gt;" id="Calendar1">

    <SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="CC75D92E-3E4D-4BCF-8490-D4F8E6E808F6"/></SelectParameters>

    <DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="CC75D92E-3E4D-4BCF-8490-D4F8E6E808F6"/></DeleteParameters>

    <UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="CC75D92E-3E4D-4BCF-8490-D4F8E6E808F6"/></UpdateParameters>

    <InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="CC75D92E-3E4D-4BCF-8490-D4F8E6E808F6"/></InsertParameters>


    The Events code only displays an empty view



  88. Helene says:

    Hi Eray,

    I ran into 2 problems concerning data view, and am hoping you could give me some heads up.

    Thanks in advance!



    I created a DFWP, and on data view properties>Editing tab> Checked the options: "Show edit links" & "Show Delete links".  My form (called ‘CustForm.aspx) replaces the default DispForm.aspx & EditForm.aspx, and I also customized the default list landing page with a Data view WP.

    I created a connection between the default view WP & the DFWP on CustForm matching the ID of the item, and also added other filters to the CustForm WP.

    Problem 1) Edit links: Save  [onclick="javascript:{ddwrt:GenFireServerEvent(‘__commit’)}"]

    I tested the Save link in CustForm edit mode: it updates the item, and works fine.  When I turn the list versioning option ON, I then get the error message "The data source command failed to execute the update command".

    I tried replacing this link with the control: <SharePoint:SaveButton runat="server" ControlMode="Edit" ID="savebutton1" />, in which case I get the error message:"An error occurred during the processing of . The ID ‘savebutton1’ is already used by another control." instead, and this happens regardless of the ID I give the the control.

    Problem 2) Delete link

    With Contribute permission level, clicking on the ‘Delete’ link brings me to an Access Denied page, but when I return to the list itself, the item has indeed been deleted.

    With higher permission level such as Content Manager, the browser stays on the same page, but I would like to redirect them to the default list page (which is also customized).

    What should I do to redirect the user to a specified url without changing their permission level?

  89. Lisa Smith says:

    I looked for a solution for this, and it is soooo easy!  

    Locate the dvt.filterfield template in the Xsl and locate the following xsl:for-each statement:

    <xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(@*[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::*[1]/@*[name()=$dvt_FieldNameNoAtSign])]/@*[name()=$dvt_FieldNameNoAtSign]">

    All I did to fix it was remove the [1], like this:

    <xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(@*[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::*/@*[name()=$dvt_FieldNameNoAtSign])]/@*[name()=$dvt_FieldNameNoAtSign]">

    found this at: http://www.sharepointblogs.com/abdrasin/archive/2007/12/06/dataviewwebpart-dataformwebpart-with-duplicate-values-in-filter-selection.aspx

  90. garfield says:

    Hello everyone,

    Without any ado….I have a data form webpart bound to an xml web service….and it is having some filtering problems.

    When i enable the toolbar for sorting/filtering it works fine but filtering does not seem to work on column headers. I have selected the basic table layout .

    When i click on column header it says "This column type can not be filtered" and is greyed out .

    Sorting is working fine.

    Now when it can filter same column types using the toolbar why it can not by column headers???

    Wat could be the reason ??

    This is how my header code looks like

    <xsl:call-template name="dvt.headerfield" ddwrt:atomic="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"&gt;

    <xsl:with-param name="fieldname">SUnN</xsl:with-param>

    <xsl:with-param name="fieldtitle">SUnN</xsl:with-param>

    <xsl:with-param name="displayname">SUnN</xsl:with-param>

    <xsl:with-param name="sortable">1</xsl:with-param>

    <xsl:with-param name="fieldtype">Text</xsl:with-param>


    I have googled enough and still dont have any clues about it.

    Please advice.

    Thanks in advance

  91. PJC says:

    Can cross list SPDataSources be linked to other SPDataSources using WSS 3.0?

    When you create a linked data source, SP Designer inserts the following script after the DVWP <DataSources> callout:

    <SharePoint:AggregateDataSource runat="server" IsSynchronous="" SeparateRoot="true" RootName="" RowsName="" ID="Unique_Combo_ID">


    <SharePoint:SPDataSource runat="server" …


    <SharePoint:SPDataSource runat="server" ….




    <concat name="data source">

    <datasource name="List1" id="0" Type="SPList"/>

    <datasource name="List2" id="1" Type="SPList"/>





    I’m assuming that it is pretty straightforward to swap out the SPDataSource script for a functioning "cross list" data source with the default "list" data source, but I don’t know how to specify a dynamic list of datasources for the <aggregate> attribute.  Any thoughts as to how to accomplish this?  Are there any other concerns that I should be aware of when attempting to link cross list data sources?



  92. Nee Okai says:


    I am not sure this is the right place, but I am desperate. From SharePoint Designer 2007, I am able to connect to AdventureWorks sample database on SQL Server 2005. But from Data Source Library window, when I right click on my "Custom Query" and click "show data" I get this error message:

    <<The server returned a non-specific error when trying to get data from the data source. Check the format and content of your query and try again. If the problem persists, contact the server administrator>>

    What am I doing wrong and how do I resolve this issue. Note that SQL server 2005 and MOSS  2007 server farm are running on the same server. SharePoint Designer 2007 is running on a client workstation.

    Thanks for any help.


  93. Dan says:

    Where does this code actually go? I tried to put it in a custom NewForm.aspx page that was working until I put the code in it. It just says the page can not be found once this type of code goes in…

  94. thewire says:

    I have the same issue as dremillard posted on Sept 24, 2007:



    I’m trying to sort and group people in the DVWP and it doesn’t seem to work.  It’s because the people (or is it person?) data type contains all of the chrome for rendering presense, etc. and so sorting an grouping don’t work as expected.  This is such a common behavior that people would want to do that I have to believe that someone has already come up with a suitable workaround.  

    I saw that you said to trim the extraneous HTML, and I did that, but it didn’t solve the sorting and grouping problem … BTW, filtering is also broken for person data types.  

    Is there a workaround, or something that I’m missing?  Thanks, Dave.


    Any solutions to this?

  95. Chris says:

    I am having an issue using this method to roll-up document libraries.

    Is it even possible?

    I have the following:

    <DataSources><SharePoint:SPDataSource runat="server" DataSourceMode="CrossList" UseInternalName="true" selectcommand="<Webs Scope=’Recursive’></Webs>

    <Lists ServerTemplate=’101′ BaseType=’1′></Lists>



    <FieldRef Name=’ID’/>

    <FieldRef Name=’ContentType’/>

    <FieldRef Name=’Title’/>


    </View>" id="dataformwebpart6"><SelectParameters>

    I have tried changing the BaseTypes and ServerTemplate which will result in either a set of blank entries or an error message.

    "The server returned a non-specific error when trying to get data from the datasource. Check the format and content of your query and try again, If the problem persists, contact your server administrator."

    Anyone have any ideas?

  96. Subhasish Bhowmick says:

    I have a custom aspz page with a dataview webpart with a linkedsource(<sharepoint:aggregatedatasource>).When I am trying to deploy this page using feature I am getting the following error

    Unable to renderwebpart.

    How to deploy pages with linked source?

  97. jerry.chen says:



  98. Chris Douglas says:

    I am trying to use lists.asmx to return the contents of a Project Tasks list to a DataViewWebPart.  In SharePoint Designer, I can create a Data Source that references lists.asmx, and it returns 17 fields.  Status is not one of those fields.  How do I get lists.asmx to return the status (Not Started, In Progress, Completed) of a task?

  99. Chris says:

    I have the same problem as Smartin,

    Has a fix every been developed for this?


  100. Maxi says:

    Has anyone solved the issue rised by PJC and Subhasish Bhowmick ?

    I’m having the very same issue!!!!!!!

  101. Salil says:

    I am using Data View Web Part to show data from 22 Doc Libraries in my page. I have enabled the Filter & Sort features of this Web Part. However the 7 Drop Down Filters are having duplicate values.

    Please find below the code snippet of the page from SPD,

        <xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(@*[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::*[1]/@*[name()=$dvt_FieldNameNoAtSign])]/@*[name()=$dvt_FieldNameNoAtSign]">

          <xsl:sort data-type="{$sorttype}" />

    When I remove [1] from it

        <xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(@*[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::*/@*[name()=$dvt_FieldNameNoAtSign])]/@*[name()=$dvt_FieldNameNoAtSign]">

          <xsl:sort data-type="{$sorttype}" />

    My page is not rendered. And I still have the dupliactes in the Drop Downs.

    Please let me know how to get rid of the Duplicate values.



  102. Vijay says:

    I’m reporting the same problem as previously reported but hopefully this comment in October 2009 will bring get someone from Microsoft to reply.

    Under my parent site (site A), I have a site (site X) which contains a custom list. Site X also contains a data view on a page (Meeting Workspace tab page) which displays the contents of the custom list. This data view can filter the columns through the column headers no problem.

    Under the same parent site (site A) I have another site (site Y) which contains another site (site Z). Site Z has a page (Meeting Workspace tab page) which has a data view displaying data from the custom list of site X. This data view cannot filter as the drop down menu from the column headers states "This column type cannot be filtered".

    Are there any solutions or workarounds to get site Z’s data view filtering the same way that site X’s data view filters?

  103. Laura says:

    Hi – can you comment on this error:

    This page allows a limit of 200 controls, and that limit has been exceeded.

    I understand there is a setting in the web.config, however I can’t understand how a web part page with a single DataFormWebPart can be over the limit of 200 controls on the page.

    I have a datasource merge of about 20 lists, with 15 columns of information on each.

    Does each field count as a control?  Thanks in advance.

  104. Sergio says:

    Hi, we are experiencing a memory leak when we use the WebUrl parameter in the data view / data form web parts. Any ideas or has someone got any workarounds or knows of any hotfixes?

    I have blogged about this here for those that are interested in reproducing it:


  105. Peter says:

    Any know how to fix PJC issue where the correct number of results come back but on the data?

    Do you need special SelectParameters or ParameterBindings?

  106. Vu says:

    Not sure if anyone has solution for David issue (May 6, 2008 9:41 AM) or not but this is the solution for sorting and filtering issue in DFWP if used with SPSqlDataSource (or SqlDataSource)



  107. Poonam says:


    I have a requirement where I have one main site and 5 sub sites. Each sub site has a document library named Projects and within each Document library I have a folder structure automatically created upon creating a folder of content type Project_Folder. The structure is as follows

    Project Folder 1

     Sub Folder1

         Sub Folder 11

         Sub Folder 12

         Sub Folder 13

         Sub Folder 14

    Sub Folder2

         Sub Folder 11

         Sub Folder 12

         Sub Folder 13

         Sub Folder 14

    Project Folder 2

     Sub Folder1

         Sub Folder 11

         Sub Folder 12

         Sub Folder 13

         Sub Folder 14

    Sub Folder2

         Sub Folder 11

         Sub Folder 12

         Sub Folder 13

         Sub Folder 14

    Also each document library in each sub site has a specific content type.

    Now I want to display documents found in folders with the name Sub Folder 11 only from all sub sites. Is that possible with the Designer DataView

  108. heguangm says:

    Hi Poonam,

    You may try to filter the documents by checking whether the document url contains "Sub Folder 11" cross sites.

    You may figure out the CAML in CamlBuilder first.

    Hopefully helps,


  109. Kevin says:

    Can you use crosslist mode with a "joined" data source? When I attempt this I get "the server retured a non-specific error when trying to get data from the data source."



  110. TxSteve says:

    Group by person. (Please note I’m a rookie) I built my first Data View in MOSS 07 and sort my data by employee name. The counts work great in the footer however the sub counts per employee return 0. I see others that have had similar results but do not see how to resolve. Something about the way SharePoint looks at names… Does anyone have a sample?

  111. SPD Data View WP says:

    Hello There,

    This is really helpful blog…I have a question here.

    here is the Requirenmetn which i got today from my client.

    1. we have one Doc Library call Documetns with column name ..rcode,dcode,dpcode,rpcode.

    2. we have one page  call alldocs.aspx where we have a DVWP which link to the Doc Libray(With Filter).

    3. I have 4 pages with same webpart (Link webpart) and when user click on any of the link they'll redirect to AllDoc.aspx.(e.g On Page1–  AllDocs.aspx?rcode="a" and on Page2 — AllDocs.aspx?dcode="b"

                                            Page3 — AllDocs.aspx?rcode="a" & rpcode = "c"   Page 4 — AllDocs.aspx?dcode="" & dpcode = ""

    Can any tell me how can i imlement this requirenment using DVWP.

    How can filter the DVWP to match the above Req.



  112. SPD Data View WP says:

    Hello There,

    This is really helpful blog…I have a question here.

    here is the Requirenmetn which i got today from my client.

    1. we have one Doc Library call Documetns with column name ..rcode,dcode,dpcode,rpcode.

    2. we have one page  call alldocs.aspx where we have a DVWP which link to the Doc Libray(With Filter).

    3. I have 4 pages with same webpart (Link webpart) and when user click on any of the link they'll redirect to AllDoc.aspx.(e.g On Page1–  AllDocs.aspx?rcode="a" and on Page2 — AllDocs.aspx?dcode="b"

                                            Page3 — AllDocs.aspx?rcode="a" & rpcode = "c"   Page 4 — AllDocs.aspx?dcode="" & dpcode = ""

    Can any tell me how can i imlement this requirenment using DVWP.

    How can filter the DVWP to match the above Req.



Skip to main content