DataGrid Edit, Update handler currency column...

G

Guest

Hi all,

Have a datagrid that displays the price column of a table.

Went to the Datagrid's Property builder and set the 'Data Formatting
expression' for the PRICE column to {0:c}, so that the dollar sign, the
comma, and the decimal are included (i.e. $44,644.48)

Managed to update the price column of the datagrid back to the database, as
long as, the user doesn't delete the dollar sign (in the 0 position).

Is there a way to change the format of the price column once the user clicks
the Edit option -so that the price column (in edit mode) doesn't have the
dollar sign and comma showing and just displays the whole number or the
decimal number for the user to change? What I'm looking for is once the user
clicks the Edit option, the '$' for the price value doesn't get displayed in
edit mode.

Any suggestions would be appreciated.

Thanks.

bebop
 
B

Brock Allen

Perhaps do a template column and for the ItemTemplate do one formatting (one
w/ currency symbol) and the EditItemTemplate just do a decimal formatting.
 
G

Guest

Thanks Brock. Using the TemplateColumn did the trick.

Used a label for the ItemTemplate and then a textbox for EditItemTemplate.
There's one thing left:

when editing the textbox of the TemplateColumn, I noticed that if a user
enters a price 456.5678 my label doesn't come back with 456.56

How do I go about fixing this? I tried using the text format(s)
{0:N},{0:F}, and then a custom format {0:#,##.##} and neither of these work.

Is there anyway to solve this? The above price also can't round up(so far
hasn't)
so, if it's 456.5678, the price is 456.56 and not 457 or 456.57

Any suggestions would be appreciated.

Thanks.

bebop
 
B

Brock Allen

I forgot if you were using a validation control. I'd suggest using one to
make sure the format is how you want it.
 
G

Guest

Where is the validation control? Do you mean a RequireFieldValidator control
to check the format inside the Template price column? Or use a regular
expression?

bebop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top