I'm generating a ListBox with preselected values as shown below . Problem is when i select an item that its keys string length is greater than 1 , listbox selects wrong items. Here is the situation ,
public static System.Web.Mvc.MultiSelectList CreateListBox()
{
List<KeyValuePair<string, string>> alanList = new List<KeyValuePair<string, string>>();
alanList.Add(new KeyValuePair<string, string>("A", "A"));
alanList.Add(new KeyValuePair<string, string>("B", "B"));
alanList.Add(new KeyValuePair<string, string>("BC", "BC"));
alanList.Add(new KeyValuePair<string, string>("C", "C"));
alanList.Add(new KeyValuePair<string, string>("D", "D"));
alanList.Add(new KeyValuePair<string, string>("BAYI", "BAYI"));
List<string> vals = new List<string>();
vals.Add("BAYI");
vals.Add("BC");
System.Web.Mvc.MultiSelectList ret = new System.Web.Mvc.MultiSelectList(alanList, "Key", "Value", vals);
return ret ;
}
In the result HTML items with values A,B and C are selected . BAYI and BC is not selected.What is the problem ? Any idea?