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 1 2809
try something like:
<ItemTemplate>
<asp:Label id=Label1 runat="server" Text='<%# Format(
DataBinder.Eval(Container,"DataItem.SubjectPrice") ) %'>
</asp:Label>
</ItemTemplate>
And in code behind place:
protected string Format(object myValue)
{
return (Convert.ToDecimal(myValue)).ToString("N",NumberFo rmat_Convert());
}
MattC
"Julius Fenata" <id****@gmx.net> wrote in message
news:er**************@TK2MSFTNGP10.phx.gbl... 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul T. Rong |
last post by:
I have a listbox (of product names) control on my form. I want to pass the
selected item (a product name) to a subform, and the product unitprice
should apear automatically next to the product name...
|
by: fotis |
last post by:
hi there
can anybody tell me if it's possible and how can i change
the name of a CheckedListBox item.I have used the Add
method to insert the item.
thank you
|
by: Dan Bass |
last post by:
Is it possible to have the item height of each item differing when selected?
I've got a scenario where each item, when it is unselected, has the same
height (OwnerDrawFixed). But when an item is...
|
by: Karen Grube |
last post by:
Hi!
I'm using a standard server side ASP.Net listbox control on a web form.
The page is basically various shades of green. The listbox itself has a pale
green background and forest green text...
|
by: Peter van der Veen |
last post by:
Hi
I have a contextmenu and i want to add to one of the items a submenu
item. I only have the name of item and want to know the index value.
How to do that?
Peter
|
by: Steve Long |
last post by:
I hope this isn't too stupid of a question but I'm looking for a way to
change an item in a listview control when the mouse moves over it. I'd like
to change its color and underline it for a...
|
by: Jeff User |
last post by:
I have my datagrid running pretty much with a EditCommandColumn and
some TemplateColumn columns.
There are two types of appearance changes I would like to make
programatically from my C# code...
|
by: aq.mahomed |
last post by:
Hi
I have the following document loaded in a System.Xml.XmlDocument.
The Document Is as follows :
<Root>
<Item></Item>
<Item></Item>
<Item></Item>
|
by: billynile |
last post by:
Hi,
I've been working on this forever now and it's starting to feel like i'm chasing my tail. Basically all I want to do is get a single node "Version" and change the text. Here's where I'm at...
|
by: OldBirdman |
last post by:
On a Report, can I change any of the fields in the "Sorting and Grouping Dialog" from within Visual Basic??? Changing the OrderBy property of the Report doesn't change anything, nor does adding an...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |