Z
zleug
Guest
Hi All.
In my form I would like to populate DataDrid by selecting value of ComboBox. The ComboBox populated with that method
public static List<Department> GetDepartments()
{
List<Department> deptdg = new List<Department>();
using (Model1 context = new Model1())
{
var departments = context.Departments.AsNoTracking().ToList();
foreach (var dt in departments)
{
Department info = new Department();
info.DepartmentId = dt.DepartmentId;
info.Department = dt.Department;
info.Description = dt.Description;
deptdg.Add(info);
}
}
return deptdg;
}
And DataGrid is populated by this method
public static IEnumerable<DepartmentEmployee> GetDepartmentEmployee()
{
using (var context=new Model1())
{
var deptemplg =
from departmentemployee in context.DepartmentEmployees
join employee in context.Employees
on departmentemployee.EmpId equals employee.EmpID
select new DepartmentEmployee
{
EmpName = employee.EmployeeName,
IsActive = departmentemployee.IsActive,
CreatedDate = departmentemployee.CreatedDate,
CreatedBy = departmentemployee.CreatedBy,
UpdatedDate = departmentemployee.UpdatedDate,
UpdatedBy = departmentemployee.UpdatedBy
};
return deptempdg.ToArray();
}
}
The entity table DepartmentEmployee has field DepartmentId like foreign key of entity of Department table. How to modify those methods to filter DataGrid by selected ComboBox value?
Thanks.
Continue reading...
In my form I would like to populate DataDrid by selecting value of ComboBox. The ComboBox populated with that method
public static List<Department> GetDepartments()
{
List<Department> deptdg = new List<Department>();
using (Model1 context = new Model1())
{
var departments = context.Departments.AsNoTracking().ToList();
foreach (var dt in departments)
{
Department info = new Department();
info.DepartmentId = dt.DepartmentId;
info.Department = dt.Department;
info.Description = dt.Description;
deptdg.Add(info);
}
}
return deptdg;
}
And DataGrid is populated by this method
public static IEnumerable<DepartmentEmployee> GetDepartmentEmployee()
{
using (var context=new Model1())
{
var deptemplg =
from departmentemployee in context.DepartmentEmployees
join employee in context.Employees
on departmentemployee.EmpId equals employee.EmpID
select new DepartmentEmployee
{
EmpName = employee.EmployeeName,
IsActive = departmentemployee.IsActive,
CreatedDate = departmentemployee.CreatedDate,
CreatedBy = departmentemployee.CreatedBy,
UpdatedDate = departmentemployee.UpdatedDate,
UpdatedBy = departmentemployee.UpdatedBy
};
return deptempdg.ToArray();
}
}
The entity table DepartmentEmployee has field DepartmentId like foreign key of entity of Department table. How to modify those methods to filter DataGrid by selected ComboBox value?
Thanks.
Continue reading...