0

i have a listView and i want a specific column has a thousand separator
i use this code but it doesnt work

<GridViewColumn x:Name="Fpricecolumn" DisplayMemberBinding="{Binding price, StringFormat={}{0:N0}$}" Header="price" Width="180"/>

but its look like this

id      price
1       2000$
2       20000$
3       1000$

(i want it like this)

id      price
1       2,000$
2       20,000$
3       1,000$

i think its becuse price column in my database (which my listView bind with that) is nvarchar(string)

Hamid
  • 13
  • 4
  • Take a look at https://stackoverflow.com/questions/31572019/separate-number-with-comma-for-thousands-asp-net – Dan Hunex Nov 07 '17 at 17:21
  • That link that @DanHunex posted with enhancement for localization seems like the answer here...not sure this would totally be invariantCulture or specific, perhaps you can elaborate a bit on your question. Note you DO need to convert to money/decimal/double etc. it would seem. – Mark Schultheiss Nov 07 '17 at 17:30
  • @DanHunex thank u...it works fine:) – Hamid Nov 07 '17 at 17:43

1 Answers1

2

You should use the currency format, which will automatically include commas and will also put the $ on the correct side:

StringFormat={}{0:C}}

You also need to make sure that your price field is actually a number.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964