I have a DataTable with a column containing numbers. I am formatting it in 0.00 format using the LINQ query below, but it is showing an error. Can anyone help me?
DT1.AsEnumerable().Select(Function(row)
row.SetField(“Number”, String.Format(“{0:0.00}”, Convert.ToDouble(row(“Number”))))
Return row
End Function).CopyToDataTable()
can you try this and let me know if it works
DT1.AsEnumerable().ToList().ForEach(Sub(row)
row.SetField(“Number”, String.Format(“{0:0.00}”, Convert.ToDouble(row(“Number”))))
End Sub)
Hello,
The SetFiled is causing the issue in your LINQ query , It modifies the row but it doent return anything. Please try the code which @chandreshsinh.jadeja has sent, it should work, and if you still face any issue then please let us know the errror msg .