Hello, I have a "Checkbox" multi-select/dropdown list in my Asp.Net MVC 5 application.
I use this code on the Razor page to create the checkbox dropdown. It displays very nicely and I can see my list of "Category".
@Html.EJS().MultiSelect("products").Placeholder("Select Categories").Mode(VisualMode.CheckBox).DataSource((IEnumerable<Category>)Model).Fields(new MultiSelectFieldSettings { Text = "Name", Value = "Id" }).Render()
How do I set the initial selected values. For example, if I have these for my categories:
ID Name
1 Category A
2 Category B
3 Category C
I want to initialize the Multiselect in the Razor page, and have Id=2 (Category B) and Id=3 (Category C) checked when the page is first rendered. I want to do it on the Razor page (server side), and not in Javascript.
I looked to see if there was a "SelectedItems" method, or "SelectedIndices", or if MultiSelectFieldSettings has a "checked" property, but no luck.
Any help would be appreciated.
Thanks!