public ActionResult GetQuantityDataforrdm(int id) { var checkStatusofGr = obj.GetDoc().Where(x => x.DocumentNo == id && x.DocStatus == "Open").FirstOrDefault(); if (checkStatusofGr != null) { ReqList li = new ReqList(); DataSet ds = li.Show_QtyMissingDataingridforrdm(id); List <ProcureVM> list = new List <ProcureVM>(); foreach (DataRow dr in ds.Tables[0].Rows) { list.Add(new ProcureVM { ItemName = dr["ItemName"].ToString(), RejectedQuantity = Convert.ToInt32(dr["MissingQuantity"]), ApprovedQuantity = Convert.ToInt32(dr["AvailableQuantity"]) }); } return(Json(list, JsonRequestBehavior.AllowGet)); } else { ReqList li = new ReqList(); DataSet ds = li.Show_QtyMissingDataingrid(id); List <ProcureVM> list = new List <ProcureVM>(); foreach (DataRow dr in ds.Tables[0].Rows) { list.Add(new ProcureVM { ItemName = dr["ItemName"].ToString(), RejectedQuantity = Convert.ToInt32(dr["MissingQuantity"]), ApprovedQuantity = Convert.ToInt32(dr["ApprovedQuantity"]) }); } return(Json(list, JsonRequestBehavior.AllowGet)); } }