mardi 7 avril 2015

DataGridView Add Multiple Rows for List in List Object

I have two classes Employee and Department as follows



class Employee
{
public string ID {get;set;}
public string Name {get;set;}
public List<Departments> AssociatedDepartment {get;set;}
}

class Department
{
public string DepartmentID {get;set;}
public string DepartmentName {get;set;}
}


I am binding a DataGridView with List<Employee>. It is showing list of Employees but not Department of the employees.



List<Employee> employeeList = GetEmployeeList();

if (employeeList != null)
{
grdResponse.DataSource = employeeList;
}


Now it is showing following data.



ID Name
---------
1 Joe
2 Tim


What should I do to get following?



ID Name Department
--------------------
1 Joe Software
1 Joe Management
2 Tim Hardware

Aucun commentaire:

Enregistrer un commentaire