We help IT Professionals succeed at work.

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

Medium Priority
1,199 Views
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
Arno
Comment
Watch Question

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%">
	<tr>
		<td>
		
<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';		
	}
	else
	{
		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; 
	} 
	else 
	{ 
		window.onload = function() 
		{ 
			oldonload(); 
			func(); 
		} 
	} 
} 
 
addLoadEvent(myCheckQueryStr); 
 
</script>
		
		
		
		</td>
	</tr>
</table>

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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

to

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

Regards
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.