Howdy,
I have a case where I have created a UserInfo CSLA Class that is used for displaying a person’s name. I have overridden the ToString method to look at a displaystyle enum in the class and to return a string of the users name formatted according to the displaystyle (First Last or Last, First or FiLast etc...)
I have another ToString that takes a displaystyle enum and returns the person’s name in that style.
I want to give this ability to the UI. When using a grid for example, I can select the UserName as a column. It displays the name using the ToString method and this works well. It displays whatever the default style is.
How can I then use the DataFormatString to modify this at the UI layer?
What do I need to add to my CSLA class so it can understand what is typed into the DataFormatString of a <ASP:BoundField>?
Aslo, Can you use the DataFormatString against a SmartDate? I have a smart date object that I want to display as well and it looks like it ignores the formatstring. If I change the property to give out a date instead of a smartdate, the formatstring works correctly.
Thank you,
Keith
It looks like I was able to answer my first question.
I made my class implement IFormattable which created a new ToString method:
Public Overloads Function ToString(ByVal format As String, ByVal formatProvider As System.IFormatProvider) As String Implements System.IFormattable.ToStringI then look at the string values of the format var and send out the person's name based on the format string that I made up.
FiLi = First Initial Last Initial (JC)
FiLn = First Initial Last Name (JCash)
FnLn = Johnny Cash
LnFn = Cash, Johnny
Still pondering if this will work for a SmartDate.
Thank you,
Keith
Brian,
Where would I add this functionality? Into the CSLA framework code and compile? I think that would be bad since I would not want to re-modify every framework update to fix my code.
Should I create a custom date object that inherits from SmartDate to add this functionality into?
Thank you,
Keith
Copyright (c) Marimer LLC