Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
MVC igCombo MultiSelection only passing selected value
posted

I have a jquery combo that is multiselection enabled with checkboxes. After I have ticked multiple items and press the submit button my model in the controllers post action only has the combos last selected item and not the multiple selected values. The MVC razor code is as follows:

        @(Html.Infragistics().ComboFor(Function(model) model.AreasToString) _
              .ID("cboAreas") _
              .MultiSelection(ComboMultiSelection.OnWithCheckboxes) _
              .DataSource(ViewData("Areas")) _
              .ValidatorOptions(Function(m) m.OnBlur(False).OnChange(False).OnSubmit(True)) _
              .ItemSeparator("|") _
              .Mode(ComboMode.DropDown) _
              .Width("200") _
              .NullText("Select Areas") _
              .Render()
        )

Lets say my items (areas) in the above example are 'North','South','East','West'. I tick 'North' and 'West' in the combo dropdown and the combo text shows "North|West". When I submit my action only receives 'West'.

Parents
  • 24497
    Verified Answer
    posted

    Hi redrabbit,

    In order to persist multiselection, the combo-field in model of your application should be type of array. Otherwise, the only single selected item can be maintained.
    Please check type of combo-field-property in your model. If it is "string", then replace it by "string[]", if it is "int", then replace it by "int[]", etc.

    Note: if you use ComboFor(...), or Combo(string), then there is no need to set ID property of combo. The ID property is designed when combo is created using blank helper like Combo().

Reply Children
No Data