StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Number,date,money formattingExpand / Collapse
Author
Message
Posted 11/21/2006 12:37:53 PM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 5:21:14 AM
Posts: 646, Visits: 22,390
OK this is probably a total noob question, but I have been struggling with it greatly.

I have a website, bound to SQL Server data. My question is about formatting of the different datatypes and data entry.

For dates I have a binding format of {0:d} and am using calendar controls for theuser to enter the dates, so proper formatting of the data entry is not an issue.

I have other fields of type money and integer and no matter what I try, I get this, Input string was not in a correct format.

When I put a BindingFormat of {0:c} the money values look pretty but when the user enters data it throws up, likewise with the integer if they put a comma.

I am new to this method of formatting and before a few days ago had never see anything like {0:c} or {0:N3}.

Can you point me in the right direction? I am guessing that the user input must match exactly what the SQL Server is expecting, but i am having issues making that happen.

Thanks
Post #4700
Posted 11/21/2006 3:48:37 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 09/26/2008 8:30:36 AM
Posts: 2,685, Visits: 1,886
The problem is not with your data formatting... the problem is with the parsing of the data back into the properties on the business object.  You'll probably need to wrap the textbox or other control you are using for data input and override the Value property (or whatever property on the control returns the value entered by the user).  All data from the users is transmitted back to the server as a string, so the string must then be parsed back into an integer or double, or whatever data type you have specified.  So, when you override the Value property, you will want to strip off all of the commas, $'s, and other symbols that are not part of the actual number, so if the user typed this: $1,000.75  then the control would return this: 1000.75 from it's Value property

It's always fun on the web


www.bungie.net
Post #4709
Posted 11/21/2006 7:25:54 PM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 5:21:14 AM
Posts: 646, Visits: 22,390
I don't like web programming much.

Thanks for the tip.
Post #4722
Posted 11/21/2006 7:34:55 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: Forum Members
Last Login: 06/19/2008 11:16:33 AM
Posts: 73, Visits: 12,471
Ben,

This is an opportune time to ask the following.  Do the controls provided by the third party providers automatically do things like the processing you are talking about?  The reason that I ask is that we are considering dropping a thousand on Infragistics and I would not be very happy if I still had to write something like this in addition to dropping the funds for the controls.

PMFJI and thanks,

CT

Post #4723
Posted 11/21/2006 9:44:04 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 3:31:03 AM
Posts: 4,586, Visits: 4,569
Infragistics controls will actually manage the data type for you so you do not run into this as when you use the inherited .NET controls.  All of the Infragistics controls have a value property that is typed as the expected value.  So when you are dealing with dates, it forces proper entry when using their UltraDateTimeEdit web control.  If you do a GetType() of the value property you will see it is typed as a DateTime rather than a string.  So you will use the IBusinessBindable interface and bind to the Value property rather than the Text property which will resolve most of your problems.

So in short, yes, Infragistics will automatically strip these types of characters that are causing you problems when you use their Value property on the control.

Post #4725
Posted 11/22/2006 7:26:46 AM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 5:21:14 AM
Posts: 646, Visits: 22,390
someone got a spare grand for me ?
Post #4730
Posted 11/22/2006 12:26:59 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 3:31:03 AM
Posts: 4,586, Visits: 4,569
  You can create your own control relatively easily.  Someday I am sure we will update our web controls to this type of format...but when we need something, we just go create a web control.  They are actually very easy and kindof fun to write.  You could do all of your parse and stripping in your control and just implement the IBusinessBindable interface.
Post #4737
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 5:38am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.125. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.