Adnan Adnan - 1 year ago 84 Question

How to round a column in a DataGridView

I am making an webpage using VB.Net that calculates the employee's yearly salary.

I have a GridView that displays a column with values of type double (they are double in the database "example: 66,556.91").

I want to round the values of this column so that I have 66,557 instead of 66,556.91.
I checked msdn, and used

and '{0:F0}' in the DataFormatString in the gridview taks - edit columns but no value was changed.

<asp:BoundField DataField="C1" HeaderText="calculated taxes" ReadOnly="True" SortExpression="C1" DataFormatString="{0:F0}" />

What do you suggest?

Answer Source

Updated your select command like this for salary column, this will perform rounding operation at database end.

SELECT ROUND(SalaryColumnName,0)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download