Well, ur 2nd dilemma is simple. In your function, create a new collection
and populate it with matches. There are a couple ways to solve your first
problem, but I'll suggest the Criteria approach used in the CSLA.Net
(
http://www.lhotka.net/ArticleIndex.a...ea=CSLA%20.NET)
I'd create a Criteria object which can have the properties you want to
filter on...something like:
public class PersonCriteria
{
private int id;
private string firstName;
priate string lastName;
//appropriate constructors and properties here
}
I'd then do:
PersonCriteria pc = new PersonCriteria( 0, null, "blah");
and I'd add the following function to the collection
public PersonCollectio n Find(PersonCrit eria pc)
{
PersonCollectio n foundCollection = new PersonCollectio n();
foreach (Person p in this.List)
{
if ((pc.Id = 0 || pc.Id = p.Id) && (pc.FirstName == null ||
pc.FirstName == p.FirstName) && ...)
{
foundCollection .Add(p);
}
}
return foundCollection ;
}
Also, check out:
http://weblogs.asp.net/plip/articles/111127.aspx
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Stanley" <st*****@glas s-images.com> wrote in message
news:Os******** ******@tk2msftn gp13.phx.gbl...
Hello all,
I have a custom collection that I am using to fill a DropDown list that
I need to filter out items based on another dropdown list. My problem is
the actual filter in the collection. I can add a filter sub to the
collection code but I am not sure how to find which property to use. Say
if my custom object is like this:
Person
ID
FirstName
LastName
And then I create a collection of Persons (using CollectionBase) how
would I be able to tell my filter sub which field I want to filter by
and how would I not lose all the records in the collection as I do not
want to have to hit the db again to get back the rest of the data that
was filtered out? Also this collection is being used for both ASP.NET
and Winforms so I need to do this in the collection not on the GUI side.
-Stanley