Posted by Vlad on October 25, 2007

If you try something like this in a GridView or DetailsView you might end up frustrated:
<asp:BoundField DataField=”Percentage” DataFormatString=”{0:f2}%” HeaderText=” Percentage” ReadOnly=”True” SortExpression=”Percentage” />
That’s because no matter what you put in the DataFormatString property, the text is formatted the same way (although the literal characters from outside the brackets do appear, so DataFormatString it’s not completely ignored).
The solution:
<asp:BoundField DataField=”Percentage” DataFormatString=”{0:f2}%” HeaderText=” Percentage” ReadOnly=”True” SortExpression=”Percentage” HtmlEncode=”false” />
Don’t know why…
Posted in .NET, ASP.NET, WCSF | Leave a Comment »
Posted by Vlad on September 28, 2007

The Web Client Software Factory provides a handy class, StateValue<T>, to use for storing values in Session. From the WCSF help:
This class supports code that runs both in a Web server environment (the session is available, and data is stored there) and outside of a Web server environment (no session is available, such as when you run your unit tests, and the data is stored in memory).
To use it, just declare a public field of StateValue<T> type and the Object Builder injects the object:
public StateValue<MyType> MyStoredValue;
To access it, just use the Value property:
MyStoredValue.Value = new MyType();
This works fine when running the application in the web server. When unit testing however, you’ll notice that the field remains null, because the object builder used for the MockCompositionContainer lacks the strategy that deals with the StateValue<T> fields. Unfortunately, the Reference Implementation that comes with WCSF doesn’t make use of these type of fields so there is no quick example on how to deal with them in tests. You can use the tests covering the builder strategies from the CompositeWeb application block tests, or you can use the following quick reference and save yourself the digging
.
Read the rest of this entry »
Posted in C#, TDD, WCSF, patterns & practices | 3 Comments »