Raju Fodse

Raju Fodse

  • 1.5k
  • 244
  • 31.2k

Json Result with Date Parameters

Jul 27 2017 6:53 AM
In MVC and want create dynamic DropDown which is depending upon Date Filed. How Can I Write Code for Json and use same in View
 
I write following Json Code
 
  1. public JsonResult GetAttnList(string ProductionDate)  
  2.         {  
  3.             Response.CacheControl = "no-cache";  
  4.             LPDBContext DB = new LPDBContext();  
  5.             List<Atten> AtnList = db.Attens.Where(x => x.ATTNDATE.ToShortDateString().Equals(ProductionDate)).ToList();   
  6.             return Json(AtnList, JsonRequestBehavior.AllowGet);  
  7.         } 
View Code is
  1. $("#PRDate").change(function () {  
  2.                 $.get("/Dailyproduction/GetAttnList", { ProductionDate: $("#PRDate").val() }, function (data) {  
  3.                     $("#ATTNSYSID").empty();  
  4.                     $.each(data, function (index, row) {  
  5.                         $("#ATTNSYSID").append("<option value='" + row.ATTNSYSID + "'>" + row.EmpName + "</option>")  
  6.                     }); 

Answers (3)