This is a migrated thread and some comments may be shown as answers.

[Solved] ListBox selected items - Binding is not working, property name is appended with []

0 Answers 5 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Raman
Top achievements
Rank 1
Raman asked on 05 Jun 2013, 03:12 PM

We have a listbox in edit view for the grid. Everything works fine but when data is saved the selected items in the listbox are not binded to ApplicationID property in the model. We checked the FormCollection and found that the property is returned as ApplicationID[] and that is why binding is not happening. We tested the functionality without grid and didn't face this issue.

 

View Model:

public class ServerViewModel
    {
        public List<int> ApplicationId
        {
            get;
            set;
 
        }
    }

View Code : 

 

 

@(Html.ListBox("Id", new MultiSelectList(ViewBag.Applications,"Value","Text", Model.ApplicationId), new { style = "width: 300px;"}))

 


Tags
Grid
Asked by
Raman
Top achievements
Rank 1
Share this question
or