I have the following method which adds a new GridCalculatedColumn to my Grid.
protected void AddCalculatedColumn(string headerText, string expression, string dataFormatString, params string[] dataFields)
{
var calculatedColumn = new GridCalculatedColumn
{
DataFields = dataFields,
HeaderText = headerText,
Expression = expression,
DataFormatString = dataFormatString,
};
Product.Columns.Add(calculatedColumn);
}
I pass 2 decimal values data fields and the expression is "{0}/({0}+{1})" and it throws a divide by 0 exception.
How to handle that when {0} or/and {1} is null then the total value which is displayed to be 0 instead of throwing this exception?
What can be set as an expression?
Thanks,
protected void AddCalculatedColumn(string headerText, string expression, string dataFormatString, params string[] dataFields)
{
var calculatedColumn = new GridCalculatedColumn
{
DataFields = dataFields,
HeaderText = headerText,
Expression = expression,
DataFormatString = dataFormatString,
};
Product.Columns.Add(calculatedColumn);
}
I pass 2 decimal values data fields and the expression is "{0}/({0}+{1})" and it throws a divide by 0 exception.
How to handle that when {0} or/and {1} is null then the total value which is displayed to be 0 instead of throwing this exception?
What can be set as an expression?
Thanks,