Tuesday, February 12, 2008

Limited Formatting in Bind

You can specify not only what property you are binding to, but also the format that should be used. Example:
<asp:TextBox Text='<% Bind("SomeProperty", "{0:N2}") %>' />
to get number with two decimal digits.

The problem is that the format is applied in one-way manner. When the number is loaded, it is formatted perfectly. But the very same number (without editing) can be stored no more. (It depends on culture. I have discovered this when using non-us decimal separators.)

No comments: