public ActionResult GetData(string address) { var bookOrderRepo = BookOrderRepo.GetBookOrderRepo(); return(Json(bookOrderRepo, JsonRequestBehavior.AllowGet)); //return View(albums); }
public ActionResult JsonGrid() { var books = BookOrderRepo.GetBookOrderRepo().Select(r => r.book).ToList(); ViewBag.RadioButtonValues = BookOrderRepo.GetBookOrderRepo().Select(r => r.book).ToList(); List <Employee> lstemp = new List <Employee>(); Employee objemp = new Employee(); IEnumerable <Employee> ietemp = EmployeeRepo.GetEmployees(); lstemp = (List <Employee>)ietemp; //StringBuilder sbHTML = new StringBuilder(); //PropertyInfo[] propertyInfos; //propertyInfos = typeof(Employee).GetProperties(BindingFlags.Public | // BindingFlags.Static); //foreach (var prop in lstemp.GetType().GetProperties()) //{ // sbHTML.Append(prop.Name); // sbHTML.Append("<br>"); //} //for (int i = 0; i < lstemp.Count; i++) //{ // foreach (PropertyInfo Property in lstemp[i].GetType().GetProperties()) // { // sbHTML.Append(Property.GetValue(lstemp[i], null)); // } //} //string str = sbHTML.ToString(); // var employeeValues = GetPropertyValues(lstemp); return(View(lstemp)); }
public ActionResult FixedWidthGrid() { var rec = tblRepo.GetRecRepo(); var bookOrderRepo = BookOrderRepo.GetBookOrderRepo(); StringBuilder sb = new StringBuilder(); //IList<PropertyInfo> propertyInfos = typeof(Employee).GetProperties(); //Employee em =new Employee(); // //add header line. // foreach (PropertyInfo propertyInfo in propertyInfos) // { // sb.Append(propertyInfo.Name).Append(","); // sb.Append(propertyInfo.GetValue(em, null)).Append(","); // } // // sb.Remove(sb.Length - 1, 1).AppendLine(); // string str = sb.ToString(); ////add value for each property. var emp = EmployeeRepo.GetEmployees(); PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Employee)); foreach (PropertyDescriptor prop in props) { sb.Append(prop.DisplayName); // header sb.Append("\t"); } // sb.Append(); foreach (Employee item in emp) { foreach (PropertyDescriptor prop in props) { sb.Append(prop.Converter.ConvertToString( prop.GetValue(item))); sb.Append("\t"); } sb.Append(""); } string str = sb.ToString(); return(View(bookOrderRepo)); }