ASP.NET MVC Model – 由 Controller – Record Filtering ( LINQ ) / 由 View – Record Filtering
由 Controller – Record Filtering ( LINQ ) |
efwdbEntities entity; public ActionResult Binding() { entity = new efwdbEntities(); … … ViewData.Model = entity.Item_Cat.Where(r => r.subcat == "NoteBook").ToList(); return View(); } |
由 View – Record Filtering |
<% foreach (var item in Model.Where(item => item.subcat == "Notebook")) { %> <tr> <td><%=item.id%></td> <td><%=item.model%></td> <td><%=item.subcat%></td> <td><%=item.cat%></td> </tr> <% } %> |