问题描述
我有一个linq查询,其中我正在使用Group By,我使用此查询绑定gridview但gridview未在gridview的所有行中正确绑定它显示
系统.Linq.Enumerable + WhereSelectEnumerableIterator2并[d> f__AnonymousType6526 [System.Nullable`1 [System.Int32],System.String,System.String,System.String,System.String,System.Int32],System.String]
我的aspx页面是:
i have a linq query in which i am using Group By and i am binding a gridview using this query but gridview is not binding properly in all rows of gridview it shows
"System.Linq.Enumerable+WhereSelectEnumerableIterator2[<>f__AnonymousType6526[System.Nullable`1[System.Int32],System.String,System.String,System.String,System.String,System.Int32],System.String]"
my aspx page is:
<Columns>
<asp:TemplateField HeaderText="Sl no." ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<div style="margin: 0px auto; width: auto;">
<asp:Label ID="lblslno" runat="server" Text='<%#Container.DisplayIndex+1 %>'>'></asp:Label>
<asp:HiddenField ID="hf" runat="server" Value='<%#Eval("EmpId") %>' />
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Employee Code." DataField="EmpCode" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField HeaderText="Employee Name" DataField="Name" />
<asp:BoundField HeaderText="Department" DataField="DeptName" />
<asp:BoundField HeaderText="Designation" DataField="DesigName" />
<asp:TemplateField HeaderText="Total Marks" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblTotalMarks" runat="server" CssClass="Label" Text='<%#Eval("Total_Mark") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Marks Secured" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblMarksSecured" runat="server" CssClass="Label" Text='<%#Eval("Total_Mark") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
我背后的代码就像
and my code behind is like
var query = (from a in TraningScheduleDetails
from b in TraningAnshwerSheet
from c in TraningAnshwerSheetDetails
from d in EmpProfessionalDetails
from e in EmpProfessionalJobDetails
from f in Department
from g in Designation
where a.TrainingScheduleDetailId == int.Parse(ddlExamDate.SelectedValue)
&& a.TrainingScheduleDetailId == b.TrainingScheduleDetailId
&& b.TrainingAnswerSheetId == c.TrainingAnswerSheetId
&& b.EmployeeProfessionalDetailId == d.EmployeeProfessionalDetailId
&& d.EmployeeProfessionalDetailId == e.EmployeeProfessionalDetailId
&& e.DepartmentId == f.DepartmentId
&& e.DesignationId == g.DesignationId
select new
{
b.EmployeeProfessionalDetailId,
Name = d.FirstName + " " + d.MiddleName + " " + d.LastName,
d.EmployeeCode,
f.DepartmentName,
g.DesignationName,
Total_Mark = total_Mark,
}).ToList();
var query2=(from a in query group a by a.EmployeeProfessionalDetailId into b
select new
{
EmpId=b.Key,
Name=b.Select(c =>c.Name),
EmpCode=b.Select(c=>c.EmployeeCode),
DeptName=b.Select(c=>c.DepartmentName),
DesigName=b.Select(c=>c.DesignationName),
Total_Mark=b.Select(c=>c.Total_Mark),
}).ToList();
grdEmployeeDetails.DataSource = query2;
grdEmployeeDetails.DataBind();
请帮忙。
please help.
推荐答案
这篇关于Gridview没有正确绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!