For doing these, we first create the model class as below:
- public class DisplayViewEntity
- {
- public List<Dictionary<string, string>> DisplayData { get; set; }
- public int TotalRecord { get; set; }
- public DisplayCommand DisplayArg { get; set; }
- }
- public class DisplayCommand
- {
- public string DisplayFieldText { get; set; }
- public string DisplayFieldName { get; set; }
- public string DisplayFieldWidth { get; set; }
- }
- public ActionResult GenericGrid()
- {
- List<Dictionary<string, string>> asd = new List<Dictionary<string, string>>();
- Dictionary<string, string> a = new Dictionary<string, string>();
- for (int i = 1; i <= 10; i++)
- {
- a = new Dictionary<string, string>();
- a.Add("A", "A" + i.ToString());
- a.Add("B", "B" + i.ToString());
- a.Add("C", "C" + i.ToString());
- a.Add("D", "D" + i.ToString());
- a.Add("E", "E" + i.ToString());
- asd.Add(a);
- }
- DisplayCommand fc = new DisplayCommand();
- fc.DisplayFieldName = "First Name,2nd Name,Third Name,Last Col";
- fc.DisplayFieldText = "A,B,C,D";
- fc.DisplayFieldWidth = "50,20,0,50";
- DisplayViewEntity fve = new DisplayViewEntity();
- fve.DisplayData = asd;
- fve.DisplayArg = fc;
- return View(fve);
- }

Join the conversation! Your thoughts help the community grow.