How do I filter a generic list in .Net2.0?

I am using asp.net 2.0 and C#.

I have a generic list,

List<EmployeeInfo> empInfoList; 

this list is loaded with the employee information. Now, I want to filter this list with the textbox value. Which is "EmploeeName".

I have to filter this list with the employeeName, and bind it to the gridview again.

I am not sure how can I do that. Please help.

Thanks in advance.

Answers


As you're using .Net2.0 you can't use LINQ, however you can use a delegate and the FindAll method:

string criteria = EmployeeName.Text.Trim().ToLower();
List<EmployeeInfo> resultList = empInfoList.FindAll(
   delegate(EmployeeInfo p)
   {
      return p.EmployeeName.ToLower().Contains(criteria);
   }
);

Need Your Help

Image library for PHP that works with metadata, resizes and crops

php image resize metadata

Do you know any PHP library that can work with the metadata of an image (author, copyright info, location... etc) and also do resizing and cropping? I use ImageMagick but I couldn't find anything a...

which is more efficient? repetitive assignment or repetitive checking

c performance optimization processing-efficiency

If I had a loop that checks for a specific value in an array and, for some reason, must iterate over all elements and cannot break midway.