Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Query linq calculatefield and decimal ?

$
0
0

Hi all,

i have a little problem with formatting a calculate field ..

i have class for example and i do some calculation on some field and place the result in a grid view

But the result is for example => 8.75155685 but i want 8.75

here is it a sample :

publicclass Stats{publicint ID {get; set; }publicDecimal amount1 {get; set; }publicDecimal amount2 {get; set; } }

Here i create a object stats with some value

 List<Stats> myList = new List<Stats>(); 
            Stats oneStats = new Stats();
            oneStats.ID = 1;
            oneStats.amount1 = Convert.ToDecimal("18,2");
            oneStats.amount2 = Convert.ToDecimal("25,25")//
            myList.Add(oneStats);

at the end i create a linq query  and assign result in a data grid view

var datas = from x in myListselectnew{ Actuel = ((x.amount1 / x.amount2) * 100)}// dataGridView1.DataSource = datas.ToList();


for the example the result is : 72,079207920792079207920792080

but i want 72,07 ..

how i can format the calculate field ?

thanks for your time


We're going to the wall in belgium !




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>