Hi, I have one table named as Date with relevant Fields Id-primary key, Name-varchar, Todate-datetime
coming to my probelm after clciking of edit button in grid view Todate value was displaying in string format
I need to display date format
Note:At the time of add everything is working fine only probelm is at edit button
Please look at my screenshot how values are displaying afer clicking of edit button

Could you please kindly help me
@{
Layout = null;
}
<html ng-app="myApp">
<head>
<title></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.8/angular.min.js"></script>
<script src="~/scripts/dirpagination.js"></script>
<script>
var app = angular.module("myApp", ['angularUtils.directives.dirPagination']);
app.filter("dateFilter", function () {
return function (item) {
if (item != null) {
return new Date(parseInt(item.substr(6)));
}
return "";
};
});
app.directive("datepicker", function () {
return {
restrict: "A",
require: "ngModel",
link: function (scope, elem, attrs, ngModelCtrl) {
var updateModel = function (dateText) {
scope.$apply(function () {
ngModelCtrl.$setViewValue(dateText);
});
};
var options = {
dateFormat: "dd/mm/yy",
showButtonPanel: true,
changeMonth: true,
changeYear: true,
onSelect: function (dateText) {
updateModel(dateText);
}
};
elem.datepicker(options);
}
}
});
app.controller("myCntrl", ['$scope', '$http','$filter', 'myService', function ($scope, $http, $filter,myService) {
$scope.mahesh = false;
GetAllTerms();
function GetAllTerms() {
var getData = myService.getterms();
getData.then(function (tc) {
$scope.terms = tc.data;
}, function (tc) {
alert("Records gathering failed!");
});
}
$scope.editState = function (state) {
debugger;
var date = $scope.ToDate;
$scope.mahesh = $scope.mahesh ? false : true;
var getData = myService.getState(state.Id);
getData.then(function (emp) {
$scope.employee = emp.data;
$scope.Id = state.Id;
$scope.Name = state.Name;
$scope.ToDate = state.ToDate;
$scope.Action = "Edit";
$("#myModal").modal('show');
},
function (msg) {
alert(msg.data);
$scope.msg = msg.data;
});
//$scope.apply();
ClearFields();
}
}]);
app.service("myService", function ($http) {
//get All countries
this.getterms = function () {
return $http.get("/master/getAll");
};
// get Employee By Id
this.getState = function (employeeID) {
var response = $http({
method: "post",
url: "/master/getEmployeeByNo1",
params: {
id: JSON.stringify(employeeID)
}
});
return response;
}
});
</script>
</head>
<body ng-controller="myCntrl">
<div class="container">
<div>
<div id="wrapper" class="clearfix" ng-show="mahesh">
<div>
<div>
<div>
<label for="ToDate">Date</label>
<input type="text" ng-model="ToDate" name="Todate" datepicker />
</div>
<div>
<div>
<label for="Name">Name</label>
<input type="text" name="Name" ng-model="Name" />
</div>
</div>
</div>
</div>
</div>
<div>
<div class="table-responsive ">
<table id="dvData" class="table">
<tr>
<th><b>Id</b></th>
<th><b>Name</b></th>
<th><b>Date</b></th>
<th><b>Actions</b></th>
</tr>
<tr dir-paginate="state in terms|orderBy:sortKey:reverse|itemsPerPage:10" ng-model="search">
<td>
{{state.Id}}
</td>
<td>
{{state.Name}}
</td>
<td>
{{state.ToDate | dateFilter | date:"dd-MM-yyyy"}}
</td>
<td>
<button type="button" ng-click="editState(state)">
Edit
</button>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
public JsonResult getEmployeeByNo1(string EmpNo)
{
try
{
int no = Convert.ToInt32(EmpNo);
var employeeList = db.Dates.Find(no);
return Json(employeeList, JsonRequestBehavior.AllowGet);
}
catch (Exception exp)
{
return Json("Error in getting record !", JsonRequestBehavior.AllowGet);
}
}