public class Product {
public int Id { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public decimal Price { get; set; }
}
public class ProductSearchRepository {
private List products = new List {
new Product { Id = 1, Name = "iPhone", Category = "Electronics", Price = 999.00m },
new Product { Id = 2, Name = "Samsung TV", Category = "Electronics", Price = 799.00m },
new Product { Id = 3, Name = "Nike Shoes", Category = "Clothing", Price = 69.99m },
new Product { Id = 4, Name = "Levis Jeans", Category = "Clothing", Price = 59.99m },
};
public IEnumerable GetCategories() {
return products.Select(p => p.Category).Distinct().OrderBy(c => c);
}
public IEnumerable SearchByCategory(string category) {
return products.Where(p => p.Category == category).OrderBy(p => p.Name);
}
}
public class ProductsController : Controller {
private ProductSearchRepository repository = new ProductSearchRepository();
public ActionResult Index(string category) {
ViewBag.Category = new SelectList(repository.GetCategories());
var products = string.IsNullOrEmpty(category) ? new List() : repository.SearchByCategory(category);
return View(products);
}
}
@model IEnumerable
@using (Html.BeginForm()) {
@Html.Label("Category:")
@Html.DropDownList("category", (IEnumerable) ViewBag.Category, "All Categories", new { onchange = "this.form.submit();" })
}
Name
Category
Price
@foreach (var product in Model) {
@product.Name
相关内容
热门资讯
透视安卓版!wepoker有什...
透视安卓版!wepoker有什么规律(透视)好像有挂(详细辅助透明教程)1、进入游戏-大厅左侧-新手...
盘点十款!wepoker透视脚...
盘点十款!wepoker透视脚本苹果版,wpk作弊最怕三个东西,分享教程(有挂神器)1、许多玩家不知...
透视系统!aapoker插件(...
透视系统!aapoker插件(透视)原来真的是有挂(详细辅助AI教程)运辅助工具,进入游戏界面。进入...
必备辅助推荐!aapoker怎...
此外,数据分析德州(hhpoker辅助软件是真的么)辅助神器app还具备辅助透视行为开挂功能,通过对...
透视数据!hhpoker作弊实...
透视数据!hhpoker作弊实战视频(透视)竟然真的有挂(详细辅助解说技巧);1、系统规律教程、辅助...
透视真的!xpoker辅助器(...
透视真的!xpoker辅助器(透视)一直有挂(详细辅助解密教程)1、下载好辅助软件之后点击打开,先需...
重要通知!佛手大菠萝13道挂哪...
1、重要通知!佛手大菠萝13道挂哪里,wepoker有辅助吗,扑克教程(有挂透视);详细教程。2、佛...
透视有挂!hhpoker有没有...
透视有挂!hhpoker有没有作弊辅助(透视)其实真的有挂(详细辅助AI教程)透视有挂!hhpoke...
重大通报!hhpoker哪个俱...
重大通报!hhpoker哪个俱乐部靠谱,德州辅助工具到底怎么样,微扑克教程(有挂透视);小薇(透视辅...
透视数据!wpk俱乐部辅助器(...
透视数据!wpk俱乐部辅助器(透视)确实存在有挂(详细辅助wepoke教程)1、上手简单,内置详细流...