Change with below code.
@{
    EHS_TrackingEntities db = new EHS_TrackingEntities(); 
    string form = ViewBag.formId.ToString();
    WebGrid webGrid = new WebGrid(source: db.tbl_detailItem.Where(x=>x.Form_Id == form));
 
    
    Layout = "~/Views/Shared/_Layout.cshtml";
}
Using below article i have created the sample.
Check the below sample.
Controller
public class HomeController : Controller
{
    // GET: Home
    public ActionResult Index()
    {
        ViewBag.Id = "ALFKI";
        return View();
    }
}
View
@{
    Layout = null;
    NorthwindEntities entities = new NorthwindEntities();
    string id = ViewBag.Id.ToString();
    WebGrid webGrid = new WebGrid(source: entities.Customers.Where(x => x.CustomerID == id));
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    @webGrid.GetHtml(
        htmlAttributes: new { @id = "WebGrid", @class = "Grid" },
        columns: webGrid.Columns(
                 webGrid.Column("CustomerID", "Customer Id"),
                 webGrid.Column("ContactName", "Customer Name"),
                 webGrid.Column("City", "City"),
                 webGrid.Column("Country", "Country")))
</body>
</html>