Hardy
Hardy
CC#
Created by Hardy on 3/20/2023 in #help
❔ DBSet manipulation
For the below code, I get all of the Customers. I want to get only those whose ID is less than 10.
// GET: Order/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Order order = db.Orders.Find(id);
if (order == null)
{
return HttpNotFound();
}

ViewBag.VesselID = new SelectList(db.Customers, "CustomerID", "CustomerName", order.CustomerID);
return View(order);
}
// GET: Order/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Order order = db.Orders.Find(id);
if (order == null)
{
return HttpNotFound();
}

ViewBag.VesselID = new SelectList(db.Customers, "CustomerID", "CustomerName", order.CustomerID);
return View(order);
}
4 replies