.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Dataview filter on querystring parameters - how to return all when empty?

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :SharePoint



I'm creating a page with a dataview wepart. The dataview is filtered by three querystring parameters. This works fine as long as all parameters are present in the querystring. The parameters currently all have defaultvalue set to "". If one parameter is missing from the querystring, the dataview returns no results (no column values matches "" they all have values). I would like it to return all results if the parameter is not present, does anyone know how to do this?


The dataview is displaying items in a Sharepoint list and currently the filter uses "equals" because I'm filtering on a MultipleLookup field type. 


I would really like to see a wildcard character in CAML like I can use % when I do this for a dataview with a sql server datasource.





View Complete Post

More Related Resource Links

Filter items with a date column with parameters start date and end date on a sharepoint list?

If I have alist with a view that has the columns Title, Status and Status Date and the view has some items. How Can I add a filter with two parameters, start date and end date, to only show records with status date equal to or greater than parameter start date and status date is less than or equal to parameter end date? This is a sharepoint online site and I can't create and deploy custom code, can use SPD though. Do I need to use SPD or is this something I can do in the list settings? Thanks in advance.   Edit: I had a look here http://www.endusersharepoint.com/2009/09/29/sharepoint-date-filter-filtering-a-list-by-greater-than-or-equal-to-date/ but I don't have the Date Filter web part.

Trying to get basic Http URL with querystring parameters processed in WCF service

I'm trying to process a post by a third party server (Paypal) processed by my server through a WCF service. All I need is to get and process the values with the query string. This sounds incredibly easy, but after a weekend, I'm still stumped.  Any help would be greatly appreciated. Passing the following URL from my browser to the service causes a AddressFilter mismatch fault (below). http://localhost:9409/PPInfo.svc/ReadResponse?RESULT=0&AUTHCODE=10001&RESPMSG=APROVED&PNREF=12345 produces <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> - <Code>   <Value>Sender</Value> - <Subcode>   <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:DestinationUnreachable</Value>   </Subcode>   </Code> - <Reason>   <Text xml:lang="en-US">The message with To 'http://localhost:9409/PPInfo.svc/ReadResponse?RESULT=0&AUTHCODE=10001&RESPMSG=APROVED&PNREF=12345' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</Text>   </Reason>   </Fault> // web.config  <system.serviceModel>     <behaviors>       <servic

how to check if a Dataview is empty?

I am having trouble with the syntax to check if my Dataview is empty.  If it is empty then the next line when I try draw information from it generates an error. How can I fix this?Dim ProjectDV As DataViewDim arg As New DataSourceSelectArgumentsProjectDV = SqlDataSource1.Select(arg)   If ProjectDV.Count <> 0 ThenpicAd.Text = LCase(ProjectDV(0)("Ad"))End If  

Return QueryString id to a FB tag not working

Here's my FB tag Asp.net<fb:like href="https://www.mysite.com/alumni/eventDetails.aspx?dateID=<%# getID() %>" width="200"> </fb:like> JavaScript:<script> window.fbAsyncInit = function () { FB.init({ appId: 'your app id', status: true, cookie: true, xfbml: true }); }; (function () { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); } ()); </script> And here's the getID() code behind:protected string getID() { string strID = Request.QueryString["dateID"].ToString(); return strID; } For some reason, I did not get an ID in the Facebook like link.

Fileupload with database parameters that need to return nothing on update

Hi All, Got a problem with regards to the file upload control on database updates. The problem is in my CMS, when a user tries to update content for a page it will add null to the fields containing the image path. What I need is for the system to check if the uploader has no image and if hasn't it has to do nothing. It can't add empty strings or null values as this will remove the original image path. Although they still need to be able to do image updates if the uploader has a file(this bits not a problem). Heres a snipet of code to demonstrate what I'm trying to achieve. protected void Button1_Click(object sender, EventArgs e) { if (Page.IsPostBack) { AddMenu menu = new AddMenu(); string APP_PATH = Server.MapPath(Common.GetAppSetting("_MENU_PATH")); if (FileUpload1.HasFile == false) { menu.Menu_Image1 = /////// Its this bit that has to do nothing //// Menu_Image1 calls a Parameter on the data layer /// Ie cmd.Parameters.AddwithValue("@image", _menu_image1) } else if (FileUpload1.HasFile) { if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.ContentLength > 0) { Uploa

Filter DataView by Value from Active Directory

I have a web part page with a dataview that is configured to display as a single item form.  The list that the dataview is pulling from will include many items, I just want to display the one item that is related to the current user so that I can populate some of the fields via javascript. The catch is, I need to match on a value in Active Directory other than logon name, username etc.  We are using a field in Active Directory to track Employee ID which is the unique ID that is used by our Finance/HR system.  I am able to use to the SPSWC:profilepropertyvalue control to display the Employee ID, I just cannot figure out how to pass that value to the dataview as a parameter to filter on. I don't have the option of a query string parameter because this is the first page the user will come to in this scenario.  I have tried both the Control and Form types of parameter but the value is never passed.  I currently have the SPSWC:profilepropertyvalue control in a div tag (I thought that if I gave the tag an ID I could reference it that way), but so far I've had no luck.  I have also tried using Javascript to take the value from the control within the div tag and assign it to a textbox, but I still cannot get the value to pass to the dataview. Here is the code for the SPSWC:profilepropertyvalue control: <table> <tr><td> <SP

Passing a Text Value as DataView Filter Parameter

I have a dataview to which I would like to pass a text value for use as a filter.  My text value is on the same page within a DIV tag that I have given an ID.  When I view the page in the browser the text is actually rendered in a SPAN tag, within the DIV tag.  I have tried the ID for both the DIV and SPAN tags when setting up the parameter, and have tried using both a parameter type of Control and Form, but nothing I've tried is working. Any thoughts?  Thanks, Chanda

Filter and Sort on fields in a joined dataview in SharePoint Designer


I need to create a data view that joins and displays data from two lists, and to sort and group on all of the fields displayed, not just fields from the main list.

I created linked datasource from two of my lists, joined them on a common field, and first inserted fields from the main list. Then I inserted fields from the other list as a Joined Subview,  which worked just fine, but now I need to be able to sort and filter on fields in that joined list, for which there doesn't seem to be an option.

Does anybody know whether it's possible and/or any workarounds/solutions for this? Basically, Is there a way to create a joined view of two lists where all fields are displayed in separate columns, and not in a table within a cell as in a case with joined subview?

Any comments are highly appreciated.


Dataview filter

Hi ALL ,

I have tried the XSLT for random display.
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[@ID=(substring(ddwrt:FormatDateTime(ddwrt:TodayIso(),1033,':mm:ss'),6,2) mod count(//Rows/Row))+1]"/>

In the designer when I refresh the data source it displays correctly ie it rotates between all items in the list.
But when i view in the browser it picks from first 10 items in the list for display, its failed to pick above 10.

So it rotates within 10 items.

Can anyone help me out


Exporting to Microsoft Excel from a DataView Web Part consuming a Web Service with Parameters

In Sharepoint Designer, I've developed a page displaying a DataView Web Part which consumes an XML Web Service with three parameters.  These parameters are passed in from a simple Form Web Part containing three input fields.  I am able to provide default values for the web service so the dataview is initially populated, and when I enter in new parameters, the web service goes back, grabs the requested data and displays in the dataview nice and slick.

The problem I'm having is this: In Internet Explorer 7, when I right-click on the DataView Web Part and select Export to Microsoft Excel, Excel opens up, says "ExternalData_1: Getting Data..." and returns the data from the web service which applies to the default parameter values each and every time, regardless of whether I have changed the parameters on the web page, and contrary to what the DataView Web Part displays on the screen.

Has anyone else run into this, and is there a solution to the problem?

Best regards,
Mark Christie

encoding function parameters and return values when binaryMessageEncoding is used


Dear All,

I'm creating simple web service that will accept some parameters (such as customer name and file name) and return content of an xml file as a string and WS client will save it on his side. I'm using custom binding with binaryMessageEncoding and httpTransport. The question is if it is possible to have these input parameters as well as returned xml content binary encoded somehow?

Thanks in advance for your help!


Filter Parameters/Search Form



I've got a gridview that I need to perform filters on. All works great until I try and add a date range..

Below is the code. Basically I have 5 dropdown lists which all filter as expected giving them the option to use each one or just the ones they need.

The problem is they want to also have the option of filtering by date i.e date range or greater than or less than or equal to etc..

As soon as I add the date parameter it stops the other filters working. I'm guessing because I have a null value in the date field (textbox) if they dont use the option??

Does anyone have a sample on how to filter by dropdown lists and dates keeping in mind they wont use all the filter options?

Thanks for any help.

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
            width: 100%;
            width: 1

How to pass multiple filter parameters to moss report viewer from custom filter provider


I have written a custom filter provider webpart which implements ITransformableFilterValues to pass parameter value to moss report viewer webpart.

However, this interface only allows to pass one parameter. Please can someone guide me through correct resource which allows my custom filter provider webpart to pass multiple parameters to report viewer. E.g if my report has 5 parameters then my filter provider webpart should allow me to make connection with report viewer and pass all 5 parameters.

Odd QueryString parameters


Hi all.

I have a partial view that implements a search box in my MVC site. The code looks like this:

<form action="/Search" method="get" id="searchForm">
    <%= Html.TextBox("t", null, new {@name = "t"}) %>
    <input id="searchimg" type="image" src="/Content/search.png" value="Search"
        title="Search" />

What I want is to get a URL with something like this when the user clicks the search image:


The thing is, that besides the QueryString parameter "t" that ASP.NET MVC creates according to my code, I'm getting two additional parameters, "x" and "y", which I have no idea where they're coming from or what good they serve, so, instead, I'm getting this:


Any thoughts? I haven't touched my default routes, by the way.


<form action="/Busqueda" method="get" id="searchForm">

DVWP filtered by 2 querystring parameters



I hope someone is able to help me solve this problem I've been having.

What I'm trying to do is this:

I currently have 2 DVWP on my page, formatted as dropdowns.   I want to have these dropdowns filter my main DVWP.   I'm doing this by the way of a querystring,  and I can get it working but with only 1 filter at a time.

I also want my main DVWP to display all records by default,  which I've also been able to do.  with something like this,  this works for only the first dropdown. 

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[@Content_x0020_Owner.title = $contentowner or $contentowner = 'All Content Owners']"/>

So I thought I could do something like this, to make it look at both dropdowns

[@Content_x0020_Owner.title = $contentowner or $contentowner = 'All Content Owners' and @Category = $categoryselect or $categoryselect = 'All Categories']"/>

but this ignores the category dropdown.  As a test,  I removed the $contentowner part, and the category filter began working.   So it has to be how I have this written.

Eventually how I want it to work,  is so that both filters can be used together.   Meaning if the user makes a selection in the first dropdown, 

Return value when empty table


I have the following code that i call from the page behind code.

when no records are in the table i get an error message


conversion from type DBNULL to type Decimal is not valid

I would prefare if the procedure did not throw this error message and returned a value to notify me that no records found when zero records returned

Public Shared Function invoicetotal(ByVal CustEmail As String) As Decimal
        ' Dim selectcommand As New SqlCommand
        Dim CONNECTION As SqlConnection = MaintainDB.GetConnectionString
        Dim sel As String _
        = "SELECT sum(total) from invoices WHERE CustEmail = @CustEmail  or  @CustEmail =   " & -1
        Dim CMD As SqlCommand = New SqlCommand(sel, CONNECTION)
        If CustEmail = "" Then
            CMD.Parameters.AddWithValue("@CustEmail", -1)


Passing Parameters like >, <, = on the Report for filter records



I dont have any idea how to proceed please help me out.

I have a Table like

ProductName        Product price

A                          2

B                          10

C                         5

I need a report where i can select the ( Greater than ,Greater Than or Equal to,Lesser than,Lesser than or Equal to, Equal To ) from the drop down list box.

and pass the credit 5. so it will get the desired results.

please advise on this .




ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend