When the Querystring is empty the Dataview webpart should display all rows

Posted on 2009-02-09
Last Modified: 2013-11-18
I have a DataView Webpart that filters according to a Querystring that is being send over from a another page.
If the Querystring has an empty value or is equal to nothing then the dataview should display all the records and no
filter should be applied.

Please help

Kind Regards
Question by:WTFISTHIS

    Accepted Solution

    Here is what I did for a work around:

    I created 2 dataviews on the same page.
    Then I put two separate Div tags around them one called "dall" and one "dfilter"
    The dataview inside the "dfilter" div I added a filter for.
    The filter will work on a Querystring which I called "myname"
    Then I used the Javascript function below to determine if the Querystring has a value or not and then just hide the "dfilter" div if the "myname" querystring is empty.

    I know it might have performance impact but that is the only solution I have at this stage.
    //put the following in content place holder tags.
    <table style="width: 100%">
    <script type="text/javascript" language="javascript">
    function myCheckQueryStr() 
    	var sQuery = document.location.toString();
    	qVar = sQuery.substring(sQuery.indexOf("Memorials=")+10);
    	if (qVar.length == 0)
    		document.getElementById("dall").style.display = '';
    		document.getElementById("dfilter").style.display = 'none';		
    		document.getElementById("dall").style.display = 'none';
    		document.getElementById("dfilter").style.display = '';		
    function addLoadEvent(func) 
    	var oldonload = window.onload; 
    	if (typeof window.onload != 'function') 
    		window.onload = func; 
    		window.onload = function() 

    Open in new window


    Author Comment

    Sorry just change the
    qVar = sQuery.substring(sQuery.indexOf("Memorials=")+10);


    qVar = sQuery.substring(sQuery.indexOf("myname=")+7);


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now