How do I use a SelectListItem in ASP.NET MVC to display choices via a List Box or Check List box -
i've been reading several articles how present choices users. use listboxfor, use checkboxfor, , there thing called multiselectlist.
what (was) confused each example seemed have done totally different way, , none of them used built in "selectlistitem" class instead created own.
so going post question asking general clarification, thought representative of other various post , repetitive.
so let me re-phrase: how use "list" or "multiselectlist" present user list of choices, including option them displayed list of check boxes?
in other words, if have following 2 items in model, how display each of them typical choice list box, or typical check list box?
public list<selectlistitem> widgets1 { get; set; } public multiselectlist widgets2 { get; set; }
warning... wanted point out "checkbox" option hangs once many choices. (e.g. changed loop 500) , won't submit.
the problem traced validation of checkboxfor line. can fixed changing 1 line to...
@html.checkboxfor(cc => cc.widgetsaschecklist[myindex].selected, new { data_val = "false", htmlattributes = new { @class = "form-control" } })
if this, can have 1,500 items in check list , submit occurs in under 3 seconds
Comments
Post a Comment