J
Julius Fenata
Dear all,
I need help to change my item-template value format...
Here is my case, I have a datagrid, with 'SubjectPrice' field, and when the
grid displayed, my 'SubjectPrice' field displayed as this format:
$30,000.00, because I put it this format {0:C}.
I need to re-format as only this value (example: 30.000 - without currency,
without decimal & using dot for thousand separator). But how to re-format my
field, considering that formatting in datagrid is limited on formatting?
I have one code to reformat into desire format (XX.XXX format), but I have
put it in my code-behind, how to applied this format into my datagrid?
Here is my code:
private NumberFormatInfo NumberFormat_Convert()
{
NumberFormatInfo myNumberFormat = new CultureInfo("id-ID").NumberFormat;
myNumberFormat.NumberGroupSeparator = ".";
myNumberFormat.NumberDecimalDigits = 0;
return myNumberFormat;
}
SubjectPrice = (Convert.ToDecimal(SubjectPrice)).ToString("N",
NumberFormat_Convert());
How to applied that format into my 'SubjectPrice' field on the datagrid?
I have thinking to change my 'SubjectPrice' into an item-template format, so
could easily put any code on it, but I haven't has any experience on this...
This is my item-template:
<ItemTemplate>
<asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.SubjectPrice", "{0:C}") %>'> // Return: $30,000.00
</asp:Label>
</ItemTemplate>
Please, kindly elaborate this case, until I got this format (Expected:
30.000 --> XX.XXX format - without currency, without decimal & using dot for
thousand separator).
Thx In Advance,
Julius Fenata
I need help to change my item-template value format...
Here is my case, I have a datagrid, with 'SubjectPrice' field, and when the
grid displayed, my 'SubjectPrice' field displayed as this format:
$30,000.00, because I put it this format {0:C}.
I need to re-format as only this value (example: 30.000 - without currency,
without decimal & using dot for thousand separator). But how to re-format my
field, considering that formatting in datagrid is limited on formatting?
I have one code to reformat into desire format (XX.XXX format), but I have
put it in my code-behind, how to applied this format into my datagrid?
Here is my code:
private NumberFormatInfo NumberFormat_Convert()
{
NumberFormatInfo myNumberFormat = new CultureInfo("id-ID").NumberFormat;
myNumberFormat.NumberGroupSeparator = ".";
myNumberFormat.NumberDecimalDigits = 0;
return myNumberFormat;
}
SubjectPrice = (Convert.ToDecimal(SubjectPrice)).ToString("N",
NumberFormat_Convert());
How to applied that format into my 'SubjectPrice' field on the datagrid?
I have thinking to change my 'SubjectPrice' into an item-template format, so
could easily put any code on it, but I haven't has any experience on this...
This is my item-template:
<ItemTemplate>
<asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.SubjectPrice", "{0:C}") %>'> // Return: $30,000.00
</asp:Label>
</ItemTemplate>
Please, kindly elaborate this case, until I got this format (Expected:
30.000 --> XX.XXX format - without currency, without decimal & using dot for
thousand separator).
Thx In Advance,
Julius Fenata