ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
AjaxCheckboxList Complex Selection
Title:
B
I
{code}
?
I have to migrate this AjaxCheckboxList function to v5. where selection var can be es: "1,3,4" public virtual ActionResult GetItems(IEnumerable<int> v, string selection) { v = v ?? new List<int>(); string selch = "," + selection; var list = new List<KeyContent> { }; for (int i = 1; i <= 7; i++) { list.Add(new KeyContent { Text = Translator.Instance.Translate("System.Weekday." + i.ToString()), Value = i, Selected = selch.Contains("," + i.ToString()) }); } return Json(list); }
Save Changes
Cancel
Meccanica Rossi
asked at 17 Jul 2017
Answers
B
I
{code}
?
the only change you need to make is go from `SelectableItem` to `KeyContent(key, content)` with `KeyContent` you don't need to specify the selected value anymore, the matching of the selected value is done by the control on the client side however if you do need to set the selected value at the server you can do this as shown here: http://demo.aspnetawesome.com/AjaxDropdownDemo#Set-value-from-get-items-call as for the `string selection` being a comma separated value, if you're binding to it using Parent or Parameter I think you should use `int[]` (int being the assumed key type)
Save Changes
Cancel
Omu
answered at 18 Jul 2017
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK