在判断ViewData[""]是否为空时,需将ViewData[""]转换为相应的类型,在判断其Count()属性是否为0,来判断是否存有值
如:<% if ((ViewData["subDepartmentsAndAmount"] as Dictionary<YouXieKu.Models.Department, int>).Count()!=0){ %>
而不能 直接通过 ViewData["subDepartmentsAndAmount"]!=null 抑或 (ViewData["subDepartmentsAndAmount"] as Dictionary<YouXieKu.Models.Department, int>)!=null