FilterProvider not getting the expect values in the method parameters

FilterProvider not getting the expect values in the method parameters

Old forum URL: forums.lhotka.net/forums/t/1996.aspx


RangerGuy posted on Monday, December 18, 2006

Hi everybody,

I know this question is been asked alot but I can't find an answer anywhere :(
So I'm hoping someone can point me in the right direction.

I created a custom provider method and pass a reference to it in my FilteredBindingList constructor.

What I don't understand is why both parameters are getting the value of the filter when the provider method is called.


I have both these methods defined with in my BusinessListBast called MyObjectList

MyFilter is a enum of types like enum MyFilter
{
   Type1 = 1,
   Type2 = 2
}


"this" is a BusinessListBase of MyObjectList.

private FilteredBindingList<MyObject> GetMyObjectType1()
{
    List < MyObject> list = new List < MyObject >();
 
    FilteredBindingList<MyObject> filteredList = new FilteredBindingList<MyObject>(this,MyFilter.Type1);

filterList.FilterProvider = MyObjectTypeFilterFunction;

filteredList .ApplyFilter("MyObjectType", enumMyObjectType.Type1);

    return filteredList;
}


//FILTER PROVIDER METHOD
private bool MyObjectTypeFilterFunction(object myobjects,object filter)
{
  try  {
     MyFilter objfilter = (MyFilter)filter;      foreach (MyObject myObj in myobjects)
    {
        if (myObj .ObjectType == objFilter)
        {
              return true;
         }
      }
      return false;
   }
   catch (Exception ex)
   {
 throw new Exception(ex.Message, ex.InnerException);
    }
 
}

RangerGuy replied on Tuesday, December 19, 2006

I just found this in a post containing a similiar question to mine.

Rocky Says:

If you pass Nothing/null for the property name, then the business object itself is passed into your filter method as the item parameter.

 

This is all I needed :| Thanks Rocky... I'm going to try it as soon as SP1 finishes installing.

Copyright (c) Marimer LLC