Adnan Adnan - 1 month ago 14
Vb.net Question

How to round a column in a DataGridView VB.net

I am making an asp.net 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

{0:D}
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

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

SELECT ROUND(SalaryColumnName,0)