<
telerik:GridDateTimeColumn UniqueName="DatePlaced" DataField="DatePlaced" HeaderText="Date Placed"
HeaderStyle-Width="160px" DataFormatString="{0:d}">
</telerik:GridDateTimeColumn>
<telerik:GridDateTimeColumn UniqueName="DateShipped" DataField="DateShipped" HeaderText="Date Shipped"
HeaderStyle-Width="160px" DataFormatString="{0:d}">
</telerik:GridDateTimeColumn>
<telerik:GridTemplateColumn DataField="DaysToShip" HeaderText="Days To Ship" >
<ItemTemplate>
<asp:Label ID="lblDaysToShip" runat="server"></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblDaysToShipFooter" runat="server"></asp:Label>
</FooterTemplate>
</telerik:GridTemplateColumn>
C# code
double
totalRows, countRows;
protected
void TrackingGrid_ItemDataBound(object source, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
(item.FindControl(
"lblDaysToShip") as Label).Text = DateTime.Parse(item["DateShipped"].Text).Subtract(DateTime.Parse(item["DatePlaced"].Text)).Days.ToString();
totalRows +=
Double.Parse((item.FindControl("lblDaysToShip") as Label).Text);
countRows += 1;
}
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = e.Item as GridFooterItem;
(footerItem.FindControl(
"lblDaysToShipFooter") as Label).Text = "Average days: " + (totalRows / countRows).ToString("N2");
}
}
Thanks for your help
Greg