I have a list of countries in a list box that I want to do an incremental search on. I have a text box above the list box and as I write I want the list of countries to be filter in accordance to the what I have written so far. For each letter typed I could simply set the datasource of the list to the results of a linq to sql statement and redo the linq statement for every letter I type. But, the interface will be used by many users and we want to avoid unnecessary round trips to the sql server.
So, I thought of doing the following:
1. On load, create an array that will hold the name of the country and its id using a linq statement
2. Set the datasource of the list to the array.
3. As I type, use linq to filter the array. This way the filtering would be in memory without the round trips to the sql server.
I am need to know how to define the array properly, getting the list display member and value member connect correctly to the array and using linq to filter the array as I type.