Hi,
I have a class called SpecialGridView that inherits from GridView
.
For other hand I have report pages that are using this SpecialGridView to show data.
The property autogeneratedcolumns was set to true, and I would like to keep this option.
To put the data format, I overrided the "CreateAutoGeneratedColumn" to parse if the data is "Decimal" stablish the format for this type of data. But I'm getting an exception "NotSupportedException"
Any idea about how to solve it?
Thanks in advance.
Here the code that I wrote:
protected override AutoGeneratedField CreateAutoGeneratedColumn(AutoGeneratedFieldProperties fieldProperties)
{
AutoGeneratedField field = new AutoGeneratedField(fieldProperties.DataField);
field.HtmlEncode = false;
string name = fieldProperties.Name;
((IStateManager)field).TrackViewState();
field.HeaderText = name;
field.SortExpression = name;
field.ReadOnly = fieldProperties.IsReadOnly;
field.DataType = fieldProperties.Type;
if (field.DataType == typeof(Decimal))
{
field.DataFormatString= "{0:0.00}";
}
return field;
}
Greetings.
Josema