I Hope this will help you!
'HTML Code
<asp:TemplateColumn HeaderText="NUMBER OF SHARES">
<HeaderStyle Width="2.5%"></HeaderStyle>
<ItemTemplate>
<%#
Format(databinder.eval(container.dataitem,"NoShares"),"#,##0;(#,##0)")
%>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"></FooterStyle>
<FooterTemplate>
<asp:Label ID="lblTotal" Runat="server"></asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
'Code Behind
Private Sub dg_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg.ItemCreated
Dim elm As ListItemType
elm = e.Item.ItemType
Dim dr As DataRow, total As Double = 0
If elm = ListItemType.Footer Then
For Each dr In Me.dt.Select()
total = total + dr.Item("NoShares")
Next
Dim lbl As Label = e.Item.FindControl("lblTotal")
lbl.Text = Format(total, "#,##0")
End If
End Sub