I want to round the column in a DataTable to two decimals. Please refer to the following code. dsBarChart is the DataSet that contains columns Development, Research, and Sustaining.
Dim dtGrid As New DataTable
dtGrid = dsBarChart.Tables(0)
' Create column for the datatable
Dim dtDevelop As New DataColumn("% Development", GetType(Decimal))
dtDevelop.Expression = "Development / (Development + Research + Sustaining)"
' Add the columns to the datatable
dtGrid.Columns.Add(dtDevelop)
I tried
dtDevelop.Expression = "Decimal.Round(Development / (Development + Research + Sustaining), 2)" and received a runtime error "The expression contains undefined function call Decimal.Round()."
I tried dtGrid.Columns.Add(Decimal.Round(dtDevelop, 2)) and received an error "Value of type 'System.Data.DataColumn' cannot be converted to 'Decimal'.)
Where can I round the number to two decimals? Thanks.
DanYeung
Dim dtGrid As New DataTable
dtGrid = dsBarChart.Tables(0)
' Create column for the datatable
Dim dtDevelop As New DataColumn("% Development", GetType(Decimal))
dtDevelop.Expression = "Development / (Development + Research + Sustaining)"
' Add the columns to the datatable
dtGrid.Columns.Add(dtDevelop)
I tried
dtDevelop.Expression = "Decimal.Round(Development / (Development + Research + Sustaining), 2)" and received a runtime error "The expression contains undefined function call Decimal.Round()."
I tried dtGrid.Columns.Add(Decimal.Round(dtDevelop, 2)) and received an error "Value of type 'System.Data.DataColumn' cannot be converted to 'Decimal'.)
Where can I round the number to two decimals? Thanks.
DanYeung