Complex Binding Help Needed

Complex Binding Help Needed

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


Scoobie posted on Tuesday, August 01, 2006

I have two lists.  One contains the State FIPS code and State name.  The second contains the State FIPS code, County FIPS code, and County name.  FIPS code are always int's.  What I need to do, in the same gridview, is display the state name in a combo box based on the FIPS code (lookup table, easily done), and based on the State displayed, display a combo box with the County names.

When a user changes the State, the County list needs to update for that row only.  Each row can have a different State, hence a different County list.

Any help is greatly appreciated.

Using VS2005 C#, CSLA 2.03

Q Johnson replied on Tuesday, August 01, 2006

Perhaps I'm not "thinking outside the box."  But I see only three obvious ways to do this and two of them are awful, so it seems an easy choice.

1 - Have separate lists objects for each state available.  Too awful to discuss further.

2 - Query the database for the county list with an input parameter for the State selected in the current row.  Also hideous.

3 - Have one list object that contains all the counties with their states - but it is Filterable.  Just change the filter to match the context of the current row. 

Sure, there will be a lot of rows - but not SO many rows that performance should suffer.  How many counties are there?  4000?  3000?  I think the median number of counties per state must be something on the order of 40 or 50.  But we have over 250 here in Texas (but you should still resist the temptation to make us a separate list object <grin>).  You may even be able to shorten the list if you can do something creative to manage duplicates.  There must be MANY instances of names like Jefferson, Washington, Green, Brown, and other names from history and general popular use (yes, even Johnson <g>).  If you could flatten the collection to contain only one row for each of those you might save 10% to 30%, I would guess.  You'd have to work out an interesting filtering algorithm, but it is probably doable.

Good luck!

Copyright (c) Marimer LLC