对象数据显示在网格视图中 [英] Object data show in grid view
问题描述
公共类LateAttendanceApprovalDto
{
公开的DateTime ApprovalDate {get;放; }
public EmployeeDto Employee {get;放; }
公共字符串备注{get;放; }
}
public class LateAttendanceApprovalDto
{
public DateTime ApprovalDate { get; set; }
public EmployeeDto Employee { get; set; }
public string Remarks { get; set; }
}
<Columns>
<asp:TemplateField ItemStyle-Width="20px">
<HeaderTemplate >
Delete
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkDelete" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="LateAttendanceApprovalID" HeaderText="LateApprovalID" ItemStyle-Width="20px" />
<asp:BoundField DataField="SubmitDate" HeaderText="Submit Date" ItemStyle-Width="20px" />
<asp:BoundField DataField="ArrivingTime" HeaderText="ArrivingTime" ItemStyle-Width="20px" />
<asp:BoundField DataField="Remarks" HeaderText="Remarks" ItemStyle-Width="20px" />
<asp:BoundField DataField="ApprovedBy" HeaderText="ApprovedBy" ItemStyle-Width="20px" />
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" ItemStyle-Width="20px" />
<asp:HyperLinkField DataNavigateUrlFields="LateAttendanceApprovalID" DataNavigateUrlFormatString="LateAttendance.aspx?LateAttendanceApprovalID={0}&Flag=y"
HeaderText="Edit" Text="Edit">
<ItemStyle Width="20px" VerticalAlign="Middle" HorizontalAlign="Center" />
</asp:HyperLinkField>
</Columns>
这是我的网格列
这里EmployeeD包含EmployeeName,EmployeeID,ApprovedBy等.现在我想在网格视图中显示LateAttendanceApprovalDto.但是批准日期和备注显示网格视图.现在网格显示ApprovalDate备注和EmployeeDto,但不显示EmployeeName,EmployeeID.如何破坏对象EmployeeDto.请帮助我.
This is my Grid column
Here EmployeeDto contain EmployeeName,EmployeeID,ApprovedBy etc.Now i want to show LateAttendanceApprovalDto in grid view .But Approval Date and Remarks show grid view.Now grid show ApprovalDate Remarks and EmployeeDto but not show EmployeeName,EmployeeID.how can break the object EmployeeDto. pls help me.
推荐答案
您不能使用显示子对象.您需要为此使用模板的语法,请参考以下链接
> http://stackoverflow.com/questions/627996/how-do-you-bind-a-gridview-column-to-a-subclass-value [ http://allen-conway-dotnet.blogspot.com/2010/05/using-child-objects-property-in.html [ http://asp.net.bigresource.com/Binding-data-to-a-GridView-from-a-Object-with-child-objects- contains-relevant-fields-8bRrTN8uH.html [
You can not show child objets with . syntax you need to use a template for that please refer the following links
http://stackoverflow.com/questions/627996/how-do-you-bind-a-gridview-column-to-a-subclass-value[^]
http://allen-conway-dotnet.blogspot.com/2010/05/using-child-objects-property-in.html[^]
http://asp.net.bigresource.com/Binding-data-to-a-GridView-from-a-Object-with-child-objects-containing-relevant-fields-8bRrTN8uH.html[^]
这篇关于对象数据显示在网格视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!