Acceessing some aggregate functions in a linq datasource in a GridView
Posted
by Stephen Pellicer
on Stack Overflow
See other posts from Stack Overflow
or by Stephen Pellicer
Published on 2009-05-11T21:26:08Z
Indexed on
2010/06/17
1:02 UTC
Read the original article
Hit count: 296
I am working on a traditional WebForms project. In the project I am trying out some Linq datasources with plans to eventually migrate to an MVC architecture. I am still very new to Linq.
I have a GridView using a Linq datasource. The entities I am showing has a to many relationship and I would like to get the maximum value of a column in the many side of the relationship.
I can show properties of the base entity in the gridview:
<asp:TemplateField HeaderText="Number" SortExpression="tJobBase.tJob.JobNumber">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("tJobBase.tJob.JobNumber") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
I can also show the count of the many related property:
<asp:TemplateField HeaderText="Number" SortExpression="tJobBase.tJob.tHourlies.Count">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("tJobBase.tJob.tHourlies.Count") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
Is there a way to get the max value of a column called WeekEnding in the tHourlies collection to show in the GridView?
© Stack Overflow or respective owner