public void AllRmbs(int portalid, int tabmoduleid, int status) { if (isFinance(tabmoduleid)) { Item tree = new Item("All Staff"); if (status == RmbStatus.Submitted || status == RmbStatus.Processing || status == RmbStatus.Paid) { StaffRmbDataContext d = new StaffRmbDataContext(); foreach (AP_Staff_Rmb rmb in from c in d.AP_Staff_Rmbs where c.Status == status && c.PortalId == portalid select c) { DotNetNuke.Entities.Users.UserInfo staffMember = DotNetNuke.Entities.Users.UserController.GetUserById(portalid, rmb.UserId); string firstLetter = (staffMember.LastName!=null?staffMember.LastName.ToUpper().Substring(0, 1):"-"); Item letter = tree.Needs(firstLetter); Item staff = letter.Needs(staffMember.LastName!=null?(staffMember.LastName + ", " + staffMember.FirstName):staffMember.DisplayName); string id = rmb.RID.ToString().PadLeft(5, '0'); Item reimbursement = staff.Needs(id + " : " + (rmb.RmbDate == null ? "" : rmb.RmbDate.Value.ToShortDateString()) + " : " + rmb.SpareField1, false); //false means reverse sort if (rmb.PrivComment != null) { reimbursement.label += " *"; } reimbursement.setRmbNo(rmb.RMBNo.ToString()); } } var result = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(new Item[] { tree }); HttpContext.Current.Response.ContentType = "application/json"; HttpContext.Current.Response.Write(result); } }