Formatting the data in my datagrid using {0:c} is the easy part, but the database rejects the currency symbols when I try to re-insert them into the database.
I've read several threads that say to use a separate "hidden" field to hold the unformatted data, but that doesn't help since the user is entering data using the currency symbol and I'd have to update the hidden field first anyway!!
Another option I'm hearing is to "strip off the currency symbol" before submitting the form to the database.
Can someone show me some code samples demonstrating "stripping" a string? I suppose the optimal way to do this would be to check for (and strip, if found) a non-numeric character at the beginning of the string, but I have no idea what the code syntax would be.
Thanks in advance...Hello, you can always store data in database using any type of characters, have you tried to use the field of currency in the database as a TEXT field, then you can store whatever data or sybmols you want in that field,
also, if you are using ms access, you might set at the table creation the type of a field to be currency and store data in it, without having to put the $ sign for example, it will directly add thaqt symbol to it!!!! but the easiet to use a Text field and don't worry about symbols.
also, in the datagrid, you migth use a templatecolumn, that you can render the way youwant to place the currency as you like,.
hope i was able to help..
best of luck.
Unfortunately I don't get to choose the datatype in the sql server tables, I have to code against what the DBA gives me!
I really just need code samples of how to test for a non-numeric character at the beginning of a string, and then strip it off it it finds one.
Thanks anyway!
string yourstring = "$50";
char firstchar = yourstring[0];
if (!( ((int)firstchar >= (int)'0') && (int)firstchar <= (int)'9') )) {
// bad, bad first char! ;)
}
0 comments:
Post a Comment