locked
VS2012 SL reusable choice lists for states and other types of static lists RRS feed

  • Question

  • I hope somebody can refer or recommend the easiest way to create a reusable choice list. For example I have screens that require selecting a state such as California or Ohio and such. There has to be a better way than manually creating several instances of a list with static data.

    Thursday, March 28, 2013 3:08 AM

Answers

  • The easiest thing to do is NOT using choice lists for this.

    Choice lists are meant for small lists of very infrequently changing data.

    In the case of a country list, simply use a dedicated table and generate a ListDetail screen for maintaining the data. (takes only 1 minute in LightSwitch)

    The list can then simply consumed in any other entity type by means of a 1 to many relation and is on screen used by means of a dropdown or a modal window picker screen.


    paul van bladel

    Thursday, March 28, 2013 5:45 AM
  • Please note that choice lists are good with up to 20 values. If you have more than 20 values, you should Always prefere a lookup table, which also seems to be necessary in your case.

    Additionally to what Paul suggested, also try to have a look at this:

    LightSwitch – Fill AutoCompleteBox with Database values


    Alessandro Del Sole
    Microsoft MVP - Visual Basic: development
    http://community.visual-basic.it/alessandro/


    Thursday, March 28, 2013 6:29 PM

All replies

  • The easiest thing to do is NOT using choice lists for this.

    Choice lists are meant for small lists of very infrequently changing data.

    In the case of a country list, simply use a dedicated table and generate a ListDetail screen for maintaining the data. (takes only 1 minute in LightSwitch)

    The list can then simply consumed in any other entity type by means of a 1 to many relation and is on screen used by means of a dropdown or a modal window picker screen.


    paul van bladel

    Thursday, March 28, 2013 5:45 AM
  • Please note that choice lists are good with up to 20 values. If you have more than 20 values, you should Always prefere a lookup table, which also seems to be necessary in your case.

    Additionally to what Paul suggested, also try to have a look at this:

    LightSwitch – Fill AutoCompleteBox with Database values


    Alessandro Del Sole
    Microsoft MVP - Visual Basic: development
    http://community.visual-basic.it/alessandro/


    Thursday, March 28, 2013 6:29 PM
  • The easiest thing to do is NOT using choice lists for this.

    Choice lists are meant for small lists of very infrequently changing data.

    In the case of a country list, simply use a dedicated table and generate a ListDetail screen for maintaining the data. (takes only 1 minute in LightSwitch)

    The list can then simply consumed in any other entity type by means of a 1 to many relation and is on screen used by means of a dropdown or a modal window picker screen.


    paul van bladel

    Thanks for the comments paul. This suggestion sounds like one of the circumstances when LightSwitch will autogenerate an AutoCompleteBox field in the table on the many side of the relation so I'm going to try it for sh!ts and giggles as it sounds like a fast way to git' er' done.
    Thursday, March 28, 2013 9:08 PM
  • Please note that choice lists are good with up to 20 values. If you have more than 20 values, you should Always prefere a lookup table, which also seems to be necessary in your case.

    Additionally to what Paul suggested, also try to have a look at this:

    http://dotnettim.wordpress.com/2011/04/12/lightswitch-fill-autocompletebox-with-database-values/


    Alessandro Del Sole
    Microsoft MVP - Visual Basic: development
    http://community.visual-basic.it/alessandro/

    On the other hand, I appreciate the comments from you  too Alessandro and agree LightSwitch lists are not that responsive when they have many values. So as arbitrary as the number 20 sounds it sounds about right in general but still leaves me with the dilemma of needing a list supporting a choice of one of the 50 states; longer lists being common to geographic metadata.
     
    I'm getting more familiar of the prolific works of Tim Leung so thanks for that reference. He documents and provides a solution to actually generate an AutoCompleteBox using data from the database and then writing the picked choice back to a table. Long list or not I'm going to have to gamble with type-ahead being used and other users will just have to hate me for it. lol
     
    As it turns out this is not much different than how I've been doing this on Web Forms so again thanks for referring to Leung who shows us how to do this the LightSwitch way.
    Thursday, March 28, 2013 9:11 PM