我有一個multiselectlist的問題,如果我將dropObjectcategories懸停在調試模式下,它包含4個應該選擇的項目。MultiSelectList does not make selected selected
List<int> selectedObjectcategoryIDs = new List<int>();
foreach (Objectcategory item in bo.Objectcategories)
{
selectedObjectcategoryIDs.Add(item.ObjectcategoryID);
}
MultiSelectList dropObjectcategories = new MultiSelectList(_bs.GetObjectcategories(), "ObjectcategoryID", "ObjectcategoryName", selectedObjectcategoryIDs);
它仍然獲取呈現不選擇任何像這樣的項目:
<select id="dropObjectcategories" multiple="multiple" name="dropObjectcategories"><option value="3">Airplanes</option><option value="10">Cars</option><option value="8">Computers</option><option value="9">Thingies</option></select>
什麼可能是錯在這裏?
/M
我已經努力使它列表而不是相同的結果 –
2009-11-23 09:05:53
_bs.GetObjectcategories()的類型是什麼?確保「ObjectcategoryID」與選定列表中的項目類型相同。 – LukLed 2009-11-23 12:18:51
_bs.GetObjectcategories()是:IQueryable和ObjectcategoryID是一個int –
2009-11-23 12:49:34