locked
Multiple DataSources in a DVWP RRS feed

  • Question

  • Can my DVWP have multiple SPDataSources each with its own SelectCommand and if so, how can I switch between the datasources in my DVWP.
    I was able to add 2 <SharePoint:SPDataSources> inside the <DataSources> tag however my DVWP seems to only use the first one.

    Any help is greatly appreciated?

    Monday, January 25, 2010 12:59 AM

Answers

  • You can indeed do this.  You'll need to have your DataSources wrapped in an AggregateDataSource.  It sounds like you're far enough along that you could probably figure it out by doing this:
    * Create a "Linked Data Source" by adding the lists you want to use in the Data Source Library panel
    * Create a new DVWP on your page with this "Linked Data Source"
    * Take a look at what SharePoint Designer give you in the DataSource section

    You'll probably have more questions at that point; I'll still be here. ;+)

    M.
    Marc D Anderson - Sympraxis Consulting LLC - Marc D Anderson's Blog - @sympmarc - jQuery Library for SharePoint Web Services
    • Marked as answer by JohnXO Monday, January 25, 2010 3:44 AM
    Monday, January 25, 2010 1:13 AM

All replies

  • You can indeed do this.  You'll need to have your DataSources wrapped in an AggregateDataSource.  It sounds like you're far enough along that you could probably figure it out by doing this:
    * Create a "Linked Data Source" by adding the lists you want to use in the Data Source Library panel
    * Create a new DVWP on your page with this "Linked Data Source"
    * Take a look at what SharePoint Designer give you in the DataSource section

    You'll probably have more questions at that point; I'll still be here. ;+)

    M.
    Marc D Anderson - Sympraxis Consulting LLC - Marc D Anderson's Blog - @sympmarc - jQuery Library for SharePoint Web Services
    • Marked as answer by JohnXO Monday, January 25, 2010 3:44 AM
    Monday, January 25, 2010 1:13 AM
  • Hi John,

    It sounds to me like you want to show data from multiple lists/sources in your dataview. You should be able to do it using SharePoint Designer and using Linked Data Source option, without modifying the code manually. These articles should help you with that:

    Display data from multiple sources in a Single Data View
    Add a linked data source



    Pman
    http://www.pmansLab.com/
    Monday, January 25, 2010 1:15 AM

  • I have a rather big SharePoint list that stores help desk tickets. In my DVWP, I wish to display the count of all tickets in their different stages (opened, in progress, etc..).
    Ex:
    Opened - 1800
    In Progress - 790
    Closed - 1500
    ...

    My DVWP will actually use this same list multiple times but with different selectcommands; one for each stage. Now I have tried using just one DataSource with a selectcommand that returns all the tickets and then doing a count on all rows for the different stages, however I noticed that the page takes a while to display from all the processing.

    When I tried using multiple DVWP each with its own seleccommand for the different stages, I noticed a much quicker page response. That is why I wish to use one DVWP only but with multiple datasources each with its own selectcommand.

    Does my approach makes sense or is there a better way to accomplish that?

    Monday, January 25, 2010 2:04 AM
  • If you're going to use the same list in the DVWP as different DataSources, I'm not sure if the performance gain will be there or not.  One thing you might want to try is indexing the stage column and see if that makes any difference. You also should reduce the columns returned if you only need the stage column, as by default the entire item is returned.  My guess is that tweaking the DVWP with the single DataSource may be the optimal route, but you'll have to fiddle with it.  The bottom line: lots of items, longer retrieval times.

    M.
    Marc D Anderson - Sympraxis Consulting LLC - Marc D Anderson's Blog - @sympmarc - jQuery Library for SharePoint Web Services
    Monday, January 25, 2010 2:16 AM
  • I was able to get my DataSources wrapped in an AggregateDataSource by merging the same list multiple times each with its own filter. Now how can I get at the number of rows for the different datasources?

    Monday, January 25, 2010 2:35 AM
  • I was able to do count of /dsQueryResponse/Rows[@agg:source='ListName']/Row
    Monday, January 25, 2010 3:44 AM
  • Glad you got it working.  The syntax you show above is a new one to me.  Generally, I'd do something like this:

    <xsl:variable name="Rows" select="/dsQueryResponse/sourcename/Rows/Row"/>
    <xsl:variable name="CountOpened" select="count($Rows[@Stage = 'Opened'])"/>
    <xsl:variable name="CountInProgress" select="count($Rows[@Stage = 'In Progress'])"/>
    etc., where sourcename is the name you provide for a DataSource in the AggregateDataSource.

    M.
    Marc D Anderson - Sympraxis Consulting LLC - Marc D Anderson's Blog - @sympmarc - jQuery Library for SharePoint Web Services
    Monday, January 25, 2010 5:02 AM