-1
如何將更多屬性添加到我的mvc列表中?現在即時將所有3個三個不同的值添加到「值」屬性「myList」。我希望列表myList具有如下屬性:Text = item,Value1 = item.resourceid,Value2 = allQuestionsid,Value3 = allCategoriesIDs。具有多個屬性的Mvc列表
List<SelectListItem> myList = new List<SelectListItem>();
foreach (var item in searchList.resources)
{
string allQuestionIDs = String.Join(", ", item.associatedQuestions.Select(q => q.id.ToString()));
string allCategoriesIDs = String.Join(", ", item.associatedQuestions.Select(q => q.categoryid.ToString()));
myList.Add(new SelectListItem { Text = item.linktext.ToString(), Value = String.Join(", ", item.resourceid, "AllQuestionsID " + allQuestionIDs, "AllCategoriesID " + allCategoriesIDs) });
}
return System.Web.Helpers.Json.Encode(myList);