Skip to content
Loading
count the number of city in mvc  
  •   
  • Although this should be done in server side, but i have no idea about your model structure.
    +3
  • Sachin Singh
    in the database the count is
    +2
  • Sachin Singh
     
    the result i am getting is
    +2
  • Dinesh Gabhane
    you can use another ViewBag for Count like below
     
     
    1. ViewBag.CityCount = _list.Count;  
    +3
  • $(document).ready(function () {
    $('.city-count').each(function () {
    $(this).prop('counter', 0).animate({
    counter: $(this).val()
    }, {
    duration: 5000,
    easing: 'swing',
    step: function (now) {
    $(this).text(math.ceil(now));
    }
    });
    });
    });
    +2
  • I want a count of cities. Here is my code which I am trying to do
     
    Controller
    public ActionResult CarList(filters filter)
    {
    ViewBag.saleCity = filter.city;
    var _list = CarInfoService.getUsedCarListByFilters(filter);
    ViewData.Model = _list;
    return View("UsedCarListParent");
    }
    +2
  • Dinesh Gabhane
    What are you getting from Controller?
    is it list? or what? 
    and how you are getting 0 count of your model?
    Can you please explain bit more 
    +2