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

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
WTFISTHISAsked:
Who is Participating?
 
WTFISTHISConnect With a Mentor Author Commented:
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

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

to

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

Regards
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.