Hello Everyone,
I have to display total time in the footer of my gridview so I have a
columnn a. I followed micrososft example to create the footer and display the
total time and it is not displaying anything in the footer of the gridview.
Below is my code
colA
9:05:45 AM
9:13:48 AM
9:14:10 AM
9:23:52 AM
9:23:52 AM
9:23:52 AM
9:23:52 AM
9:24:51 AM
9:24:51 AM
9:25:03 AM
9:25:10 AM
-------------
TotalTime:
protected void dgAgentActivity_RowDataBound(object sender,
GridViewRowEventArgs e)
{
TableCell cell = e.Row.Cells[18];
DateTime itemTotal1 = DateTime.Parse(itemTotal);
DateTime dt2 = new DateTime();
TimeSpan dt1 = new System.TimeSpan(
Int32.Parse(itemTotal1.Hour.ToString()),
Int32.Parse(itemTotal1.Minute.ToString()),
Int32.Parse(itemTotal1.Second.ToString()));
DateTime ts = dt2.Add(dt1);
DateTime orderTotal = ts;
protected void dgAgentActivity_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
// Get the OrderTotalLabel Label control in the footer row.
Label total = (Label)e.Row.FindControl("TotalTime");
// Display the grand total of the order formatted as currency.
if (total != null)
{
total.Text = orderTotal.ToString("c");
}
}
}
global variable
private DateTime orderTotal= new DateTime();
amd aspx page template column lloks like this
<asp:GridView ID="dgAgentActivity" runat="server"
AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
BackColor="AliceBlue" OnRowDataBound="dgAgentActivity_RowDataBound"
OnRowCreated="dgAgentActivity_RowCreated" ShowFooter="true">
<Columns>
<asp:templatefield headertext="SwitchTime"
itemstyle-horizontalalign="Right"
footerstyle-horizontalalign="Right"
footerstyle-backcolor="Blue"
footerstyle-forecolor="White">
<itemtemplate>
<%#Eval("SwitchTime", "{0:c}")%>
</itemtemplate>
<footertemplate>
<asp:label id="TotalTime"
runat="server"/>
</footertemplate>
</asp:templatefield>
</Columns>
</asp:GridView>
above is the 18th column. I am not showing all other columns.
Any help will be appreciated.