Hi guys,
I'm applying the DataFormatString in codeBehind for our grid (it is dinamic) and it work very well.
I Attached a event on AutoGeneratingColumn and when it occurs, I apply everything that I need.
The problem is, that I created an ExpressionColumn, and on it, my DataFormatString doesn't work.
Here's the code:
Thanks in advance!
I'm applying the DataFormatString in codeBehind for our grid (it is dinamic) and it work very well.
I Attached a event on AutoGeneratingColumn and when it occurs, I apply everything that I need.
(e.Column as GridViewDataColumn).DataFormatString = "#,0.00";
The problem is, that I created an ExpressionColumn, and on it, my DataFormatString doesn't work.
Here's the code:
e.Column = new GridViewExpressionColumn();
if(c.Mascara != null)
(e.Column as GridViewExpressionColumn).DataFormatString = "#,0.00";
RadExpressionEditor a = new RadExpressionEditor();
// creates the item
var type = ClassFactory.Instance.GetDynamicClass(Table.Columns.Select(col => new System.Linq.Dynamic.DynamicProperty(col.ColumnName, col.DataType)));
var item = Activator.CreateInstance(type);
foreach (var row in Table.Rows)
{
foreach (var prop in type.GetProperties())
{
if (row[prop.Name] != null)
{
if (prop.PropertyType == typeof(DateTime?))
prop.SetValue(item, new Nullable<
DateTime
>(Convert.ToDateTime(row[prop.Name])), null);
else
prop.SetValue(item, row[prop.Name], null);
}
else
prop.SetValue(item, null, null);
}
break;
}
a.Item = item;
System.Linq.Expressions.Expression expression;
a.TryParse(c.Expressao, out expression);
if (expression != null)
(e.Column as GridViewExpressionColumn).Expression = expression;
Thanks in advance!