Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:42:03+00:00 2026-05-30T07:42:03+00:00

As titled. So I was successfully to put DataTable into my CollectionView with using:

  • 0

As titled.

So I was successfully to put DataTable into my CollectionView with using:

    ICollectionView _collectionView { get; set; }
    public ICollectionView collectionView {......}

            DataTable myDataTable= new DataTable();
            myConnection.Open();
            dbAdpater.Fill(myDataTable);
            myConnection.Close();
            var collectionList= (newLeadTable as IListSource).GetList();
            this.collectionView = CollectionViewSource.GetDefaultView(collectionList);

I know each of the object in the list is DataRowView and as I tested with iterating the data and I can see is stored properly.

The DataGrid was display properly when I execute the code.

But once I added the Filter:

            this.collectionView.Filter = new Predicate<object>(
                (obj) =>
                {
                    return false; //Just for testing propose
                }
            );

When I execute the code is giving me error:

Cannot create instance of ‘Window1’ defined in assembly ‘TestWPF,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Exception has
been thrown by the target of an invocation. Error in markup file
‘TestWPF;component/Window1.xaml’ Line 1 Position 9.

And output:

A first chance exception of type ‘System.NotSupportedException’
occurred in PresentationFramework.dll

I also tried to stores converts the DataTable into a list of custom object for filtering, but is working fine.

So I wonder what did I done wrong when filtering with DataTable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:42:04+00:00Added an answer on May 30, 2026 at 7:42 am

    See http://msdn.microsoft.com/en-us/library/ms752347.aspx#binding_to_collections

    To improve performance, collection views for ADO.NET DataTable or DataView objects delegate sorting and filtering to the DataView.

    The BindingListCollectionView does not support filtering. Instead, you have to use the CustomFilter property which takes a filter string and uses it as the value for the underlying DataView.RowFilter property. The string value is SQL that you would use to construct the WHERE clause in a SELECT query.

    this.collectionView.CustomFilter = "Price > 20";
    

    If you want to use multiple conditions, then you have to string them together with AND or OR (just like SQL).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using EWS managed api v1.1, I can successfully save/set the contact Title or honorific
We've put frustrating hours into the attempt to get a remarkably simple script to
When submitting a form to create a new object i get an error message
I need to set alarm in google calendar via Android app. I have successfully
I decided to put my login form into an element and render it on
Using jquery fitted* plugin, if I put a rel =external on the clickable area
the title already tells the question: you can successfully call the Print-Method on a
Title says what i'm trying to do. I can successfully generate an assembly if
I currently have the following objects persisting successfully: Person first name, etc. Exams title,
In the section titled 'Memory Warnings' here http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmNibObjects.html , I don't follow why the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.