0

I have the control below derived from a BoundField, used inside a GridView, as in the markup below the code. My problem is that the control renders the literal value of it's DataFormatString, not a formatted representation of it's data value.

public class BoundReportField : BoundField
{
    public override string DataFormatString
    {
        get
        {
            var baseString = base.DataFormatString;
            if (!string.IsNullOrWhiteSpace(baseString))
            {
                return FormatStrings.Currency;
            }
            return baseString;
        }
        set
        {
            base.DataFormatString = value;
        }
    }

    protected override string FormatDataValue(object dataValue, bool encode)
    {
        var val = base.FormatDataValue(dataValue, encode);
        return val;
    }
}

<avm:BoundReportField DataField="BOND_AMOUNT" DataFormatString="R #\,###\,###" />
ProfK
  • 49,207
  • 121
  • 399
  • 775

2 Answers2

2

Try doing this in your markup:

DataFormatString="{0:R #\,###\,###}"

EDIT
Removed extra quote

James Johnson
  • 45,496
  • 8
  • 73
  • 110
1

sorry my other was wrong, I believe your format string needs to follow this format DataFormatString="{0:D6}" so change it to look like this "{0:R #\,###\,###}"

kmcc049
  • 2,783
  • 17
  • 13