How can I display two decimal points after a number?
I have tried following:
var hrs = (from p in Hours.Where(h.UserName == UserName())
group p by p.Hours into g
select g.Sum(p => p.Hours)).Sum().ToString("#.##");
return Json(new { data = Convert.ToDouble(hrs).ToString("#.##") });
But it doesn't display anything on UI without Convert.ToDouble()
and ToString("#.##")
it displays hours "9"
How do we format results that we get by querying databases like above?