-
Nov 11th, 2012, 01:23 AM
#1
Thread Starter
Lively Member
[RESOLVED] rounding values
Hi Friends
I've a datatable that developed by my colleague and filled at HTML table (old stayle programming)
HTML Code:
<tr>
<th>City1</th>
<td><%=string.Format("{0:0}", dtHour.Compute("max(field1)", string.Empty))%></td>
<td><%=string.Format("{0:0}", dtHour.Compute("min(field1)", string.Empty))%></td>
<td><%=dtHour.Compute("round(avg(field1),0)", string.Empty)%></td>
<td><%=dtHour.Compute("sum(field1)", string.Empty)%></td>
</tr>
but the value which I get is decimal, I'm trying to round it but dose not work and getting the following error:
please can anyone help to solve that error and rounding decimal value?
Regards
-
Nov 11th, 2012, 02:11 AM
#2
Re: rounding values
You can't just make up syntax. Have you read the documentation for the DataTable.Compute method to see what it supports? Presumably not, or you wouldn't have tried to use that in the first place. There is no such function so you can't use it. You can use Compute to calculate the average and then use Math.Round or Decimal.Round to round the result.
-
Nov 11th, 2012, 03:09 AM
#3
Thread Starter
Lively Member
Re: rounding values
Thank you so much for your quick response
I've found a simple solution for that issue as follow:
<tr>
<th>City1</th>
<td><%=string.Format("{0:0}", dtHour.Compute("max(field1)", string.Empty))%></td>
<td><%=string.Format("{0:0}", dtHour.Compute("min(field1)", string.Empty))%></td>
<td><%=string.Format("{0:0}", dtHour.Compute("avg(field1)", string.Empty))%></td>
<td><%=string.Format("{0:0}", dtHour.Compute("sum(field1)", string.Empty))%></td>
</tr>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|