运行时出现 id 空错误。这是我所有的部分。
这是我的 DAL,ProjectDB
public static List<Product> IsOrganic(int lotid)
{
using (var db = new ProductDB())
{ //Selects from database in SQL what we need
//IsDamaged is Organic, and bool for true/false for food
DbCommand cmd = db.GetSqlStringCommand("SELECT * FROM PRODUCTS WHERE ORGANIC = 1");
return FillList(db.ExecuteDataSet(cmd));
}
}
这是我的经理
public List<Product> IsOrganic(int lotid)
{
return ProductDB.IsOrganic(lotid);
}
这是我的控制器
public ActionResult Organic(int id)//Store/Organic
{
ProductManager mgr = new ProductManager();
var list = mgr.IsOrganic(id);
return View(list);
}
另外,这是我的全球
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);