My C# class is as follows
public class SeatPlans
{
public int Id { get; set; }
public string seat_id { get; set; }
public string seat_no { get; set; }
public int layout_id { get; set; }
}
I have created a list of class object as follows
List<SeatPlans> allUser = new List<SeatPlans>();
but what I need is an array of lists so that I can access the data of several objects like allUser[0], allUser[1], allUser[2]
My controller code is as follows
public JsonResult getdata(int seat_plane_id)
{
int lid = seat_plane_id;
layoutsController L = new layoutsController();
JsonResult result = L.getlayouts(lid);
List<layouts> L1 = (List<layouts>)result.Data;
List<List<SeatPlans>> allUser = new List<List<SeatPlans>>();
for (int i = 0; i < L1.Count; i++)
{
String lid1 = L1[i].ticket_no_start;
lid = Int32.Parse(lid1);
allUser[i] = db.SEATPLAN.Where(d => d.layout_id == lid).ToList();
}
var v = new { allUser = allUser[0], allUser1 = allUser[1] };
return Json(v, JsonRequestBehavior.AllowGet);
}
I'm getting
System.ArgumentOutOfRangeException exception
at
allUser[i] = db.SEATPLAN.Where(d => d.layout_id == lid).ToList();
allUser[0]. So getting the Id would beallUser[0].Id