Thursday, 30 August 2012

Formatting a FormView data bound string


Instead of:
<asp:Label ID="Label_Age" runat="server" 
Text='<%# Eval("CalculatedAgeMonths") %>' />

Use:
<asp:Label ID="Label_Age" runat="server" 
Text='<%#  ConvertToYearsMonths(Eval("CalculatedAgeMonths")) %>' />


And in your code behind:
Function ConvertToYearsMonths(CurrentMonths As Integer) As String

     Return "in Years!!"

End Function

No comments:

Post a Comment