从SQL数据库表检索到的下拉列表中的数据筛选为特定值

时间:2019-05-21 12:11:27

标签: c# sql-server asp.net-mvc entity-framework

我试图在MVC 5项目中创建一个下拉列表,该列表中的列表项是从SQL Table获取并由于特定值而被过滤的。 这是我的控制器:

"clang++.exe: warning: argument unused during compilation: '-Wa,--noexecstack' [-Wunused-command-line-argument]"

这是我的观点:

public ActionResult Create()
{
    ViewBag.CarID= new SelectList(db.Customers, "CarID", "LastName");

    ViewBag.CodeID= new SelectList(db.Movies, "CodeID", "Damage_Subtype");
    return View();
}

这可行,但是它检索了所有数据并填充了DDL。我想要的是过滤输入中的选定项目。

我的SQLtable: My SQL table where all data are here

但是我希望此数据按Damage_Type进行过滤,而在文本框中输入损坏的类型(如电),DDL将相应地进行过滤:

Filtered Data that has to be grabbed to the corresponding DDL

我希望我能很好地解释问题。 谢谢...

0 个答案:

没有答案