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
- public JsonResult GetAttnList(string ProductionDate)
- {
- Response.CacheControl = "no-cache";
- LPDBContext DB = new LPDBContext();
- List<Atten> AtnList = db.Attens.Where(x => x.ATTNDATE.ToShortDateString().Equals(ProductionDate)).ToList();
- return Json(AtnList, JsonRequestBehavior.AllowGet);
- }
View Code is
- $("#PRDate").change(function () {
- $.get("/Dailyproduction/GetAttnList", { ProductionDate: $("#PRDate").val() }, function (data) {
- $("#ATTNSYSID").empty();
- $.each(data, function (index, row) {
- $("#ATTNSYSID").append("<option value='" + row.ATTNSYSID + "'>" + row.EmpName + "</option>")
- });