Reputation: 1281
I want to round down column values after division aplied:
DataColumn maxSpend = new DataColumn();
maxSpend.DataType = System.Type.GetType("System.Double");
maxSpend.Expression = string.Format("{0:0.00} / price", this.maxSpend);
Its possible somehow to use Math.floor() in column expression or are there other solutions for this ?
Upvotes: 1
Views: 3240
Reputation: 460108
.NET functions are not allowed in DataColumn-Expressions. The easiest would be to do it in the first place in the the dbms(if you're using any).
For example in SQL-Server: SELECT FLOOR(MaxSpend/Price)AS MaxSpend ...
.
The other way is looping through the DataRows. For example:
foreach (DataRow row in tbl.Rows)
{
double price = row.Field<double>("price");
row["maxSpend"] = Math.Floor(this.maxSpend / price);
}
Upvotes: 2