I'm currently struggling with the MultiSelect inside a Grid Editor Template in that the posted model has too many strings.
This is from my editor template...
My string array, "key_messages" is defined in my controller
In my model
Using fiddler, I can see that the posted data contains way too many objects. For example, if I select "work ethic" and "efficiency", I get the following.
To make matters worse, if I save this, then attempt to remove one of the "work ethics", I get this (even though only two selections remain)...
I'm assuming that this is some type of serialization problems but I've not been able to put my finger on the problem.
Please help.
This is from my editor template...
@(Html.Kendo().MultiSelectFor(model => model.messages)
.Name(
"key_messages"
) // With or without makes no difference
.Placeholder(
"Select Key Messages"
)
.BindTo((System.String[])ViewData[
"key_messages"
]))
My string array, "key_messages" is defined in my controller
string
[] key_messages = {
"work ethic"
,
"efficiency"
,
"fiscal"
};
ViewData[
"messages"
] = key_messages;
In my model
public
string
[] key_messages {
get
;
set
; } //I've also tried using List<string> with same results
Using fiddler, I can see that the posted data contains way too many objects. For example, if I select "work ethic" and "efficiency", I get the following.
key_messages[0]
key_messages[1] work ethic
key_messages[2] work ethic
key_messages[3] efficiency
To make matters worse, if I save this, then attempt to remove one of the "work ethics", I get this (even though only two selections remain)...
key_messages[0]
key_messages[1] work ethic
key_messages[2] work ethic
key_messages[3] efficiency
key_messages[4] work ethic
key_messages[5] efficiency
I'm assuming that this is some type of serialization problems but I've not been able to put my finger on the problem.
Please help.