Search code examples
c#asp.netgridviewdevexpressaspxgridview

How to add currency format to Data Row in AspxPivotGrid by Programmatically?


I want to add currency format to Data Row in AspxPivotGrid table. You can see the below picture,how it is displaying now. So I just want to display currency format to 3 fields (ExtendedPrice,ExtendedCost,Profit)

Now how it is displaying

This is my c# code:

if (i == 8 || i == 9 || i == 10 || i == 11)
{
    DevExpress.Web.ASPxPivotGrid.PivotGridField newF = new DevExpress.Web.ASPxPivotGrid.PivotGridField(names[i], PivotArea.DataArea);
    newF.ID = "field" + newF.FieldName;
    //newF.ValueFormat.FormatType=
    ASPxPivotGrid1.Fields.Add(newF);
}

Solution

  • Per this doc (FormatInfo) I think it should be set like that:

    newF.ValueFormat.FormatType = FormatType.Numeric;
    newF.ValueFormat.FormatString = "c2";