I have a List of employees where each list item also contains a List of the times (punches) where they accessed different departments.
I'd like to display the data in a GridView (ID: GridView1) that contains BoundField columns for both ID and Name as well as a TemplateField column for a nested GridView (ID: GridView2) which would show the list of Departments, Shifts and Times.
public class PunchInfo
{
public string DepartmentName { get; set; }
public int Shift { get; set; }
public DateTime Time { get; set; }
}
public class Employees
{
public string Id { get; set; }
public string Name { get; set; }
public List<PunchInfo> Punches { get; set; }
}
I'd like to do it in the .cs file, but I don't know how to go about binding the data to the grid.
/* EmployeeList is List<Employees> */
GridView1.DataSource = EmployeeList;
GridView gv2 = GridView1.FindControl("GridView2") as GridView;
/* How to bind the EmployeeList[row_idx].Punches to the nested GridView2 object? */
GridView1.DataBind();
Thanks