May 22, 2009, 10:06 AM
[CLOSED] How to format a decimal number...
I have a decimal number that needs to show with commas as the separator and 2 places after the decimal.
I need to display the number in a text box and in a datagrid. Right now it displays with no commas, and doesn't show the precision (i.e. 1000.50 shows up as 1000.5 instead of 1,000.50).
Any suggestions?
Dim Goal As Decimal = dr("Goal")
ContractsDefaultGoal.Text = FormatNumber(Goal, 2)
<ext:NumberField runat="server" ID="ContractsDefaultGoal" FieldLabel="Goal" Width="75" BlankText="0.00" DecimalPrecision="2" AllowNegative="false" AllowBlank="false" AllowDecimals="true" EmptyText="0.00" ValidateOnBlur="true" MaxValue="99999999"></ext:NumberField>
<ext:Store runat="server" ID="Store2" DataSourceID="SqlDataSource2" AutoLoad="true">
<Reader>
<ext:JsonReader ReaderID="ID">
<Fields>
<ext:RecordField Name="Goal" Type="Float" />
<ext:RecordField Name="DisplayNumber" Type="String" />
<ext:RecordField Name="Notes" Type="String" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:GridPanel runat="server" ID="GridPanel1" Title="Goals - Double Click to Edit" Width="300" Height="500" StoreID="Store2" AutoScroll="true" ButtonAlign="Center" HideHeaders="true">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column DataIndex="DisplayNumber" ColumnID="DisplayNumber" Header="" Align="Left"></ext:Column>
<ext:Column DataIndex="Goal" ColumnID="Goal" Header="" Align="Right">
<Editor>
<ext:NumberField runat="server" ID="ContractsGoal" FieldLabel="Goal" Width="75" BlankText="0.00" DecimalPrecision="2" AllowNegative="false" AllowBlank="false" AllowDecimals="true" EmptyText="0.00" ValidateOnBlur="true" MaxValue="99999999"></ext:NumberField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>