c# - Formatting dynamically created column -
i have asp grid contents generated dynamically using sql procedure.
using procedure datatable returned binded grid. in grid have cost column round 4 decimal places(12.1234). how same?
i tried in rowdatabound as
if (e.row.rowtype == datacontrolrowtype.datarow) { e.row.cells[4].text = string.format("{0:n4}", e.row.cells[4].text); } but has no effect. cannot apply formatting datatable using cost calculations rounding cost cause problems.
any appreciated
you should convert variable type string decimal/double type , apply format:
if (e.row.rowtype == datacontrolrowtype.datarow) { e.row.cells[4].text = convert.todecimal(e.row.cells[4].text).tostring("#.####"); }
Comments
Post a Comment