0

我在两个数据表中取得了价值

Dt1

EMPID empname  sickleave  casual leave  earned leave
1      john                            1

Dt2

EmpId  empname  sickleave  casualleave  earned leave
 1      john      5          5           5

在 dt2 中,休假的默认值是给定的(员工的总休假),而在 dt1 中,给出了员工休假的时间。所以我想以这种形式在网格中显示结果,例如

Empname sickleave casualleave earnedleave
john       0/5       0/5          1/5

for this i wrote code like this

 var result = from p in dt1.AsEnumerable()
                                 join q in dt2.AsEnumerable() on p.Field<int>("EmpID") equals q.Field<int>("EmpID") into UP
                                 from q in UP.DefaultIfEmpty()

                                 select new
                                 {
                                     EmpID = p.Field<int>("EmpID"),
                                     EmpName = p.Field<string>("EmpName"),

                                     SickLeave = (p.Field<int?>("Sick Leave") ?? 0).ToString() + "/" + (q.Field<int?>("Sick Leave") ?? 0).ToString(),
                                     CasualLeave = (p.Field<int?>("Casual Leave") ?? 0).ToString() + "/" + (q.Field<int?>("Casual Leave") ?? 0).ToString(), 
                                     EarnedLeave = (p.Field<int?>("Earned Leave") ?? 0).ToString() + "/" + (q.Field<int?>("Earned Leave") ?? 0).ToString()
                                 };

                    GridViewLeaveSummary.DataSource = result;
                    GridViewLeaveSummary.DataBind();

这段代码工作正常,但我想让休假动态意味着网格根据休假类型表显示没有休假(意味着所有离开字段都来自数据表),因为我必须添加不同的休假类型。在这段代码中,给出了三个叶子,并且我必须在网格中添加更多的叶子 .means 没有叶子显示根据数据库

谢谢

4

0 回答 0