MultiSelectList(items, dataValueField, dataTextField, selectedValues) constructor expects four parameters:
- items collection - you are passing them correctly
- dataValueField
string
- here is your first error. You should pass name of value field instead of passing all values. - dataTextField
string
- here is your second error. You should pass name of text field instead of passing all text values. - selectedValues collection - here is your third error. You should pass values only (that is
1
and5
in your case) instead of passing items which have selected values.
So, correct code is
new MultiSelectList(items, "Key", "Value", new [] { 1, 5 })
I suggest you to read carefully error messages, look on IntelliSense hints, and use MSDN to get information about types you are using.