/// <summary>
/// Returns the Sum of specified column in the datatable
/// </summary>
/// <param name="columnName"></param>
/// <param name="dtSource"></param>
/// <returns>Decimal. The source column should be in decimal format</returns>
public static decimal GetColumnTotal(string columnName, DataTable dtSource)
{
decimal total = 0;
try
{ total = dtSource.AsEnumerable().Sum(o => Convert.ToDecimal(o.Field<object>(columnName))); }
catch
{ }
return total;
}
/// Returns the Sum of specified column in the datatable
/// </summary>
/// <param name="columnName"></param>
/// <param name="dtSource"></param>
/// <returns>Decimal. The source column should be in decimal format</returns>
public static decimal GetColumnTotal(string columnName, DataTable dtSource)
{
decimal total = 0;
try
{ total = dtSource.AsEnumerable().Sum(o => Convert.ToDecimal(o.Field<object>(columnName))); }
catch
{ }
return total;
}
No comments:
Post a Comment