I am using System.Linq.Dynamic
to invoke actions dynamically , Attached below my code.
void InvokeAction(object gv, string lambda) {
var e = myalias.DynamicExpression.ParseLambda(gv.GetType(), null, lambda);
e.Compile().DynamicInvoke(gv);
}
var gv = new GridView();
gv.DataSource = (new int[] {
1,
2,
3,
4,
5
}).Select(p => new {
f1 = "f1", f2 = "f2", f3 = "f3"
});
gv.DataBind();
InvokeAction(gv, "HeaderRow.Cells[0].Text = \"a\"");
// Runs fine , but does not update the value
InvokeAction(gv, "HeaderStyle.BackColor = System.Drawing.Color.White");
// Gives exception No property or field 'System' exists in type 'GridView'
First call to InvokeAction runs fine , but does not update the value . Second call to InvokeAction throws exception
No property or field 'System' exists in type 'GridView'