Answered Querystring and dataview filter by name

  • Friday, May 04, 2012 8:40 AM
     
     

    I've created a dataview with a Querystring filter. This works when I do this on ID but it does not work when I use another field like title.

    How can I solve this.

All Replies

  • Friday, May 04, 2012 8:49 AM
     
     

    Hi

    can you provide more infos/details? How you defined the filter for ex?


    Romeo Donca, Orange Romania (MCSE, MCTS, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • Friday, May 04, 2012 10:51 AM
     
     Answered

    If you have added the dataview at a custom list form (Display or New or Edit) this is expected. Because, ID is by default passed in the QueryString when either of the forms are called.

    Eg: When you click on any listItem, the URL formed would be http://yourSite/ListName/Forms/DispForm.aspx?ID=1.

    As you can see, ID is available in the QueryString but not Title. You would need to have the URL generated with the Title field (if the URL is getting generated in another custom page for instance), or use the Title field ($Title) in your DataView.

    You can go through a couple of articles where fields are accessed and edited for more details.Eg: http://blog.sharedove.com/adisjugo/index.php/2011/06/26/setting-a-link-target-in-the-sharepoint-2010-data-view-web-part/

    https://www.nothingbutsharepoint.com/sites/eusp/Pages/data-view-web-part-the-basics-add-a-hyperlink.aspx

    If you have any specific issue than this ...let us know.

    Hope this helps...


    -Sangeetha

    • Marked As Answer by Remco Hooijer Monday, May 07, 2012 11:28 AM
    •  
  • Friday, May 04, 2012 1:39 PM
     
     

    I am not sure of how you are getting your Query-string, but this link leads to how to adjust Query-strings with drop-down boxes. http://social.technet.microsoft.com/Forums/en-US/sharepoint2010customization/thread/84e0ac90-f5cb-4451-b2fe-57d0e73e5172


    As for how to filter a data view based on a query string, Go to your list in data view through SharePoint Designer. Select your web-part and from the top ribbon go Options under the Data View Tools Category. Select Filter, this will bring up a dialogue box. In here you are going to click on Add new Clause, and you are going to select the field you want to filter, so if you want the title select Title, if you want customfield1 select customfield1. For your comparison use equals, and for the value create a new Parameter. The Parameter Source should be Query String, and the Query String Variable should be what your Query String is called. For example, in the article I mentioned above, "Project" is the Query String being used, and the address reflecting it is "http://servername/default.aspx?Project=xxxx".

    If you would like to find the title as mentioned above, you can use "Title" as your Query String, and your address would be "http://servername/default.aspx?Title=somerandomtitle"

    If you have any questions regarding this please feel free to ask.