[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1189
  • Last Modified:

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
0
WTFISTHIS
Asked:
WTFISTHIS
  • 2
1 Solution
 
WTFISTHISAuthor 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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now