2017-08-14 171 views
0

我在一個泡菜裏克,我需要一些幫助。以下是表單中我的選擇列表的代碼。我需要根據他們從類別列表中選擇的類別來填充認證列表。我如何得到這個工作?從其他選擇列表中選擇列表人口

CODE:

// GET: INT_CertificationsXREF/Create 
public IActionResult Create() 
{ 
    ViewBag.FullName = UserInformation.Globals.FullName; 
    ViewData["INT_CertificationCategoriesID"] = new SelectList(_context.INT_CertificationCategories, "ID", "Category"); 
    ViewData["INT_CertificationConferredID"] = new SelectList(_context.INT_CertificationConferred, "ID", "ConferredBy"); 
    ViewData["INT_CertificationsID"] = new SelectList(_context.INT_Certifications, "ID", "Certification").Where(i => i.CategoryID = ViewData["INT_CertificationCategoriesID"]); 
    ViewData["RIM_ResourceID"] = new SelectList(_context.RIM_Resource, "ID", "FirstName"); 
    return View(); 
} 
+0

你不能,除非你是傳遞一個類別ID。現在你只是在獲得,它不會傳遞任何參數。您可能必須執行AJAX請求來填充您的認證。另外,PICKLE RICK! – justiceorjustus

+0

搜索「Cascading DropDownList」,您會發現很多關於此概念的信息。這個想法是,你從一組選擇開始,只有一組開始,然後根據選擇進行AJAX調用以填充後續列表 – randcd

+0

這可能會給你一些想法https://www.cloudscribe.com/docs/easy -cascading,下拉菜單 –

回答

0

您可以使用該功能的B名單過濾列表A中包含

ViewData["INT_CertificationCategoriesID"] = new SelectList(_context.INT_CertificationCategories, "ID", "Category"); 
    ViewData["INT_CertificationConferredID"] = new SelectList(_context.INT_CertificationConferred, "ID", "ConferredBy"); 
    ViewData["INT_CertificationsID"] = new SelectList(_context.INT_Certifications, "ID", "Certification").Where(i => i.CategoryID.Contains(_context.INT_CertificationCategories.ID)); 
    ViewData["RIM_ResourceID"] = new SelectList(_context.RIM_Resource, "ID", "FirstName");