Search code examples
c#.netasp.netgridviewtableadapter

What's the best way of rounding numbers in an ASP.NET GridView bounded to a DataTable?


I have a GridView that is bound to a DataTable, which in turn uses a TableAdapter, like so:

ResultTableAdapter tableAdapter = new ResultTableAdapter();
ResultDataTable dataTable= tableAdapter.GetResult(id);
gridView.DataSource = dataTable;

This gridview displays many columns with numbers in them. Now I have to display the numbers in thousands with one decimal.

E.g. the number "24753" from the database should be displayed like "24,8" in the gridview.

What's the cleanest way of accomplishing?


Solution

  • I ended up changing the contents of the GridView afterwards, since I found no fast and nice solution to display the numbers in thousands. But it feels wrong.