I am trying to format my Gridview columns to display decimal values upto 2 places after the decimal point.
I am aware of both DataFormatString='{0:0.00}
for the boundfield and also Eval("NumFailedFiles", "{0:0.00}")
for ItemTemplate.
But i want this to be configurable, i.e. i want to get the no. of decimal places from the database and apply to the boundfield or itemtemplate. For acheiving this i have tried formatting in gridview_RowDataBound Event but in vain.
GridDecimal = Convert.ToInt32(resXResourceSet.GetString("GridMaxDecimals"));
var field = gridView.Columns[1] as BoundField;
field.DataFormatString = "{0:0.00}";
With this code i am encountering an exception which says
"Object reference not set to an instance of an object"
at the 3rd line of the above code.
Can someone help me on how to achieve this for both boundfield and Itemtemplate
This is my datasource to clear the ambiguity
My data source: