.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

Filter expression not working

Posted By:      Posted Date: October 16, 2010    Points: 0   Category :ASP.Net

Hi, I am using a GridView and I require the user to be able to filter using 2 controls. One simply filters the type of row - there is a column called action, and the user selects one of the distinct values from the database in a dropdown box, and the gridview only displays the rows with that value in the action column. On it's own this works perfect.

But I am also adding a textbox where the user can type in an ID of either the 'itemID', or the 'parentID'. This works fine even with the previous control.

Problem is, the dropdown box does not work when the textbox is empty (i.e. all ID's are being shown). If I choose a value and click Submit, it just doesn't do anything. Now if I am filtering by ID and then choose a value from the dropdown box, it works perfect.

Here is my filter expression and parameters of the datasource:


 <asp:SqlDataSource ID="SqlDataSource1" runat="server"  
        ConnectionString="cleared for privacy" 
        SelectCommand="SELECT * FROM [Audit] WHERE ([source] = @source)" FilterExpression="action like '{0}%' and (itemID like '{1}' or parentID like '{1}')"> 
            <asp:Parameter DefaultValue="LOGISTICS" Name="source&quo

View Complete Post

More Related Resource Links

Hi this method is working fine need filter how


private void GetData()
        for (int i = 0; i < Gridview1.Rows.Count; i++)
            DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            DataRowView drv = dv[i];

Can the default member for the sql server analysis filter web part be a mdx expression or not

I have designed a dashboard , some parametrized reports ( on date and time) in my case with a cube as datasource, added an analysis services 2005 filter, connected it to the reports. The issue concerns the default value for the filter . I f I choose [Date Local].[Calendar Hierarchy].[All] it works well. But the business requirement is to use the last day where there have been registered a measurement which in my case looks like the following mdx expression: Tail( Filter ([Date Local].[Date Key].[Date Key].Members , ( ( [Advisor Organisation].[Advisor organisation].[Contact Center].&[Denmark]&[Kundelinjen], [Measures].[Calls Offered] , [Date Local].[DK Holiday].&[False] , [Date Local].[Week Day].&[True] ) > 0 ) ), 1).Item(0).Item(0) The expression is all right as I use it in my report as an mdx filter expression. But when I use apply it I get an invalid dafault member value. So the question is : Does the filter support an mdx expression ? If yes, is there another syntax or change in order to make it work ? Thank you a lot for your answer.

Out-of-box filter stops working as soon as I "Configure Datasource"

I'm running VWD 2008 Express with ASP.NET 3.5 I realize now that 4 has much better filtering controls, but I didn't realize that when I started my project.  Anyway, when I use the standard List.aspx to display a table, the filtering works just fine (yes, it's only foreign keys and booleans, but it works).  I then modify the linq datasource so that the gridview only displays the columns that I want, and the filter function immediately stops working.  You can choose from the drop down lists, but nothing happens.  As an aside, I don't want to set scaffolding to false for those columns because I do want them to show up in the Edit.aspx page.  My understanding is that scaffolding settings would keep the field from showing up in either page. What do I need to include in either the gridview or the linqdatasource to get the filter working again?   Thanks!

MS Filter pack for Zip files content search not working

I am facing a problem related to Zip files content search. Searching of content inside zip files doesn't return in search results. But searching for zip file name returns filename in search results. I look into Crawler log, all it says is:   Steps I followed to install MS Filter pack: Installed MS Filter Pack 1.0 (x64) http://support.microsoft.com/kb/946336/en-gb In Search Administration page added "zip" in File types Add Reg subkey under : "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\12.0\Search\Setup\ContentIndexCommon\Filters\Extension\" for ".zip" with value ={20E823C2-62F3-4638-96BD-90F4F6784EBC} Stop and Start oSearch Run full crawl of content sources Can you please advise or have any tips you got to resolve this. Thanks http://portal/testzip.zip Crawled (The filtering process could not load the item. This is possibly caused by an unrecognized item format or item corruption. )

XPath expression not working for Google Maps return XML

I have this XMLdocument:<kml><Response><name>3051,netherlands</name><Status><code>200</code><request>geocode</request></Status><Placemark id="p1"><address>3051 Rotterdam, The Netherlands</address><AddressDetails Accuracy="5"><Country><CountryNameCode>NL</CountryNameCode><CountryName>Nederland</CountryName><AdministrativeArea><AdministrativeAreaName>Zuid-Holland</AdministrativeAreaName><Locality><LocalityName>Rotterdam</LocalityName><PostalCode><PostalCodeNumber>3051</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails><ExtendedData><LatLonBox north="51.9497984" south="51.9402954" east="4.4907255" west="4.4656367"/></ExtendedData><Point><coordinates>4.4767883,51.9458650,0</coordinates></Point></Placemark></Response></kml>I used this site: http://www.xmlme.com/XpathTool.aspxwhere I enter the expression: "kml/Response/Placemark/Point/coordinates"I then get the right value. HOWEVER, when I place this code in .NET, the xpath expression returns nothing:req = HttpWebRequest.Create("http://maps.google.com/maps/geo?output=x

filter expression/ colour cells


I have a DropDownList the uses the filter expression for the results to be displayed into a gridview.

I also have code to colour the cell colour according to a specified value taken from when the record is created, unfortunately I cannot get this later part to work correctly.


                <asp:ListItem Selected="True">Concern</asp:ListItem>

                ConnectionString="<%$ ConnectionStrings:myDBConnectionString %>"
                FilterExpression="IssueType='{0}'" SelectCommandType="StoredProcedure">
                    <asp:ControlParameter Name="IssueType" ControlId="DropDownList1" PropertyName="SelectedValue"/>

Full text search not working for pre-existing data on table after installing docx filter.However wor


Hello All,


I have a strange issue. I have pre-existing data in my table with full text index defined along with catalog. I noticed that I did not have the docx filter ,so I installed the filter and performed the steps below. After installing the filter  I added a couple of new records. I noticed that the full text search pulled up the new records matching the criteria but did not return any pre-existing records. Could you please let me know the issue.Please note – currently I am using sql 2008 , but also would like to verify the same in sql 2005 as well.

Also could you please verify the steps below for installation in sql 2008 and sql 2005 and with different architectures (Eg windows 2003/2008, 32bit, 64 bit etc)


This was tested on VM image on 64 bit architecture Windows 200

Switching Filter Expression


I have an Gridview for which I initially programmed an option to use a drop down box with values for filter expressions. It enables to select a subset of records and then choose to select one.

initial setup

I received a request to allow searching on some fields in a grid view. So I presented a choice to switch between these hard coded filter expressions and selecting a database field and typing in a search string:

Choice of search or filter

If user clicks the radiobutton to Search the controls change to databasefield,searchbox,submitsearch:

search option

My submit search button has this code:

Dim filterExpression As String = DropDownList3.SelectedValue + " LIKE '%" & TextBox2.Text & "%'"
Dim filterparameters As String = "TextBox2.Text"

SqlDataSource1.FilterExpression = filterExpression

The resulting search works very well and switching betwe

Filter on web part not working for certain columns


Hi all,

I have a list of "Faults" - this contains the Shop Number that the fault was logged against (which is a lookup column to the "Shops" list), who logged the fault ("Created By") and the details of the fault ("Title").

If I add the list as a web part and filter by Created By, it works perfectly - I get multiple entries in the list for all faults logged by a certain person.

However, if I filter by a Shop Number - I only get a handful of entries in the list, going back a few days - anything older than that is simply not there.

Yet if I go to the main page for the Faults List (AllItems.aspx) and change to Datasheet view - the filter works perfectly, I can see EVERY entry for a particular Shop when filtering on Shop Number.

Any ideas? It only seems to happen when using a Web part OR a DFWP - as a result, I can't pass the Shop Number as a filter parameter to it, nor can the users see a complete history of faults when viewing individual shops.

I've no idea what has changed recently, other than deletng some custom views we had created in the Faults list - could this have caused a problem? Can the Faults list be "reset" somehow without losing any data? To clarify - it's ONLY happenning when the list is viewed as a web part of DFWP, when it's viewed in Datasheet m

mdx - filter "not working" when i use equals zero


I'm filtering customers, depending on some other dimension and measure. If I use > , <, = with any number different than 0, it works fine. < and > works even with 0, but = "doesn't work"

this is my query>



dynamic set Segment0 as





The filter attribute not working



Sql DD 3.5 scaffold  - website(not project)

Why its not working when I call the filter like this?

public partial class OrderDetail { }
public class OrderDetailsMetaData
    [Filter(FilterControl = "FilterFKCustom")]
    public object Order { get; set; }

The filter is working only if I register the control on the page..

(The filter located on a folder name Filters under the DynamicData and not register in the web.config under controls><add..)


Working with SharePoint document libraries

Document libraries are collections of files that you can share with team members on a Web based on Microsoft Windows SharePoint Services. For example, you can create a library of common documents for a project, and team members can use their Web browsers to find the files, read them, and make comments. Users with Microsoft Office 2003 can check out and edit the files as if they resided on a local or network drive.

By default, your team Web site comes with a built-in document library named Shared Documents, which is listed on the Quick Launch bar as well as on the Documents and Lists page.

Using jQuery to Filter Table Rows

The project is using the .net GridView control, so I had limited control over the output HTML code. Still, I think this code can work for most tables. One thing to notice: you should use the class "filterable" on your table or on one of its parents for the code to work.
First, we need a text box:

GridView Multiple Filter AJAX Control

This AJAX control enables the user to filter data within any column inside a GridView. The user can add multiple filters and can delete existing ones too.

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

Row command working on all rows not selected one?



I have this code that hides a column in a gridview.  (The column houses another nested gridview).

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "Select" Then
            If GridView1.Columns(0).Visible = False Then
                GridView1.Columns(0).Visible = True
                GridView1.Columns(0).Visible = False
            End If
        End If
    End Sub

The trouble is that if I click the select link on one row that action to hide is carried out on all rows.  How can I set this up so that it only hides the row that is selected?


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