/// <summary> /// 绑定类别 /// </summary> /// <param name="_pid"></param> private void TreeBind(int _pid) { List <MaterialCategory> list = _material.List().ToList(); List <SelectListItem> selectList = new List <SelectListItem>(); foreach (MaterialCategory contry in list) { string Title = contry.MaterialName; if (contry.MaterialCategoryId == _pid) { selectList.Add(new SelectListItem() { Value = contry.MaterialCategoryId.ToString(), Text = Title, Selected = true }); } else { selectList.Add(new SelectListItem() { Value = contry.MaterialCategoryId.ToString(), Text = Title }); } } ViewBag.MaterialCategory = selectList; }
public ActionResult List(int page = 1, int size = 20) { var pageIndex = page; var pageSize = size; var totalCount = 0; var list = _material.List(pageIndex, pageSize, ref totalCount).ToList(); var personsAsIPagedList = new StaticPagedList <MaterialCategory>(list, pageIndex, pageSize, totalCount); return(View(personsAsIPagedList)); }