DataGrid dynamic data example question

Hi, Sir,

I am trying to use the dymaic binding of Datagrid component. Referenced by the example, I had setup Property="@GetColumnPropertyExpression(column.Key, column.Value)

Also in the code, I had the following function.
public string GetColumnPropertyExpression(string name, Type type)
var expression = $@"it[""{name}""].ToString()";
return type == typeof(int) ? $"int.Parse({expression})" : expression;
However, what about the other data types? I had tried to use datatime etc, it will failed
The binary operator Equal is not defined for the types 'System.String' and 'System.DateTime'
How should I fix this error?

You can extend our example with more types. For example DateTime:

Seems Great!
Thanks you, @enchev.

What if key is missing in the dictionary?

Looks like there is some expression try parsing under the hood, I cannot use null propagation or inspecting the dictionary directly, e.g.

var expression = $@"(it.ContainsKey(""{name}"") ? it[""{name}""].ToString() : ""--"")";