在判断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

posted on 2011-04-24 14:01  露水丛生  阅读(1082)  评论(0编辑  收藏  举报