Format Double
Needed some help with the following code. I am trying to format the result to a decimal ##0.00 this is the first time I am trying to work with C# and need some help. Thank you
I have tried to modify the code and I just can't get this correct.
if (this.DataSource.BalanceSpecified) {
string formattedValue = this.DataSource.Format(TblPaymentRequestTable.Balance);
formattedValue = HttpUtility.HtmlEncode(formattedValue);
if(formattedValue != null){
int maxLength = formattedValue.Length;
if (maxLength > (int)(100.00)){
maxLength = (int)(100.00);
}
if (maxLength == (int)(100.00)) {
formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0,maxLength));
formattedValue = formattedValue + "...";
}
}
this.Balance.Text = formattedValue;
} else {
this.Balance.Text = TblPaymentRequestTable.Balance.Format(TblPaymentRequestTable.Balance.DefaultValue);
}
Niradhip ChakrabortyPosted Jul 6, 2009, 3:30 AM
if (this.DataSource.BalanceSpecified)
{
string formattedValue = this.DataSource.Format(TblPaymentRequestTable.Balance);
formattedValue = HttpUtility.HtmlEncode(formattedValue);
if(formattedValue != null)
{
int maxLength = formattedValue.Length;
if (maxLength > (int)(100.00))
{
maxLength = (int)(100.00);
}
if (maxLength == (int)(100.00))
{
formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0,maxLength));
formattedValue = formattedValue + "...";
}
}
this.Balance.Text = Convert.ToDouble(formattedValue).ToString("C");
} else
{
this.Balance.Text = TblPaymentRequestTable.Balance.Format(TblPaymentRequestTable.Balance.DefaultValue);
}
Alex LeonPosted Jul 4, 2009, 4:07 PM
Can you show me your example but include my code?
Thank you
Niradhip ChakrabortyPosted Jul 1, 2009, 5:57 AM
Convert.ToDouble(formattedValue).ToString("C");