ASP.NET Methods:
String.Format Method:
Is used to format the strings. Each format item is replaced with the string representation of the equivalent argument in a parameter list. If the value of the argument is null, it is replaced with empty string.
Most commonly used formats:
· Separating amount by comma for thousands:
String to be formatted: 1234567
Textbox.Text= String.Format("{0:#,###0}", 1234567)
Result:1,234,567
· Gridview formatting for bound fields:
<asp:BoundField DataField="PhoneNumber" DataFormatString="{0:(###) ###-####}" />
· Gridview formatting for Template <itemtemplate> fields:
<ItemTemplate>
<asp:Label ID="GrossFloorArea" runat="server"Text='<%#String.Format("{0:#,###0}", Int64.Parse(Eval("GrossFloorArea").ToString()))%>'></asp:Label>
</ItemTemplate>
No comments:
Post a Comment