What I found from your code is in footer you have taken the label lblSubTotal:
<FooterTemplate>
<asp:Label ID="lblsubTotal" runat="server" />
</FooterTemplate>
But in code you are accessing using lblTotal:
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblTotal = (Label)e.Row.FindControl("lblTotal");
lblTotal.Text = stotal.ToString();
}
so it is throwing an exception stating that object reference not found.
try putting correct name of the label at the following place:
Label lblTotal = (Label)e.Row.FindControl("lblSubTotal");
Hope this helps.