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
2060
igCombo multiselect binding
posted

I'm defining a combo as follows:

          @(Html.Infragistics().ComboFor(model => model.SelectedRoleIdsString)
                    .MultiSelectionSettings(msc =>
                    {
                      msc.ShowCheckBoxes(true);
                      msc.Enabled(true);
                      msc.ItemSeparator(",");
                    })
                    .DataSource(Model.AvailableRoleNames)
                    .TextKey("Text")
                    .ValueKey("Value")
                    .DataBind()
                    .Render()
          )
Originally I started off with SelectedRoleIds defined as an array of integers, but this didn't cause the existing values to be selected in the combo.  Then I changed SelectedRoleIds to be a comma separated string and that still didn't work and then finally I changed it to an array of strings and now the existing selected roles are shown in the text area when the page loads.  So, for example, if I set the values as follows it works:

SelectedRoleIdsString = new string[] {"1", "2"};

However, if I update the selection in the combo control, it appears that the selected values are then returned in a single element string array with all of the values put into a comma separated string in the first element of the array: https://imgur.com/a/fZ6ap  I.e. the format required for getting the data to display is different to the format that is then submitted back?
Is this right, and if so why does it work like that and where is this discussed in the documentation?
Thanks, Tom