บทความ

กำลังแสดงโพสต์จาก 2014

ASP.NET MVC with select2

CONTROLLER 1: public JsonResult GetSupplier( string keyword) 2: { 3: var data = ( from s in DataContext.Supplier 4: join st in DataContext.SupplierType on s.SupplierTypeId equals st.Id 5: select new { supplierId = s.Id, supplierName = s.Name + "(" + st.Name + ")" }); 6:   7: return Json( 8: string .IsNullOrEmpty(keyword) ? 9: data.Select(c => new { id = c.supplierId, name = c.supplierName }) : 10: data.Where(c => c.supplierName.StartsWith(keyword)).Select(c => new { id = c.supplierId, name = c.supplierName }), JsonRequestBehavior.AllowGet); 11: } 12:   13:   14:   15:   16: public JsonResult GetSupplierById( int supplierId) 17: { 18: var data = ( from s in DataContext.Supplier ...