RIAS
asked on
Format column on datatable
Hello,
How can I format this code on datasource
dg is my datagridview and int is the number
instead on dg(int) how can I use datasource
Cheers
How can I format this code on datasource
dg(int).Columns("Total").DefaultCellStyle.Format = "N2"
dg is my datagridview and int is the number
instead on dg(int) how can I use datasource
Cheers
Basically - you can't. You can format strings and store these in the databable but numbers you do that when you display them.
ASKER
The problem is that it is a money field.
You format the value when you display it. (Separating data and UI in designing the app)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers Pawan!
Cheers Rias !!
Just one update..
<<SELECT * , CASE WHEN CHARINDEX('.',a,0) > 0 THEN SUBSTRING(CAST(a AS VARCHAR(10)),0,CHARINDEX(' .',a,0)+3) ELSE a END FormattedColumn FROM CTE>>
Just one update..
<<SELECT * , CASE WHEN CHARINDEX('.',a,0) > 0 THEN SUBSTRING(CAST(a AS VARCHAR(10)),0,CHARINDEX('
Do you want to do this in datatable? , You can do that in the query itself.