-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Description
When binding a System.Data.DataTable to a WPF DataGrid, if the DataColumn.ColumnName contains a "," (Comma), all subsequent cells in that column fail to display values.
In the output, it throws the binding error as ,
System.Windows.Data Error: 40 : BindingExpression path error: '[]' property not found on 'object' ''DataRowView' (HashCode=20668333)'. BindingExpression:Path=[a,b_0]; DataItem='DataRowView' (HashCode=20668333); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
Datatable codes:
DataTable dataTable = new DataTable();
dataTable.Columns.Add("a,b", typeof(int));
dataTable.Columns.Add("cb", typeof(string));
dataTable.Columns.Add("Customer ID", typeof(string));
dataTable.Columns.Add("Country", typeof(string));
dataTable.Rows.Add(1001, "Maria Anders", "ALFKI", "Germany");
dataTable.Rows.Add(1002, "Ana Trujilo", "ANATR", "Mexico");
dataTable.Rows.Add(1003, "Antonio Moreno", "ENDGY", "Mexico");
Column Declaration:
private void FradataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
e.Column = new DataGridTextColumn { Header = e.Column.Header, Binding = new Binding("[" + e.Column.Header + "]") };
}
Sample Attached: DataGrid_WPF.zip
Reproduction Steps
- Run the attached sample.
- Observe the column "a,b0".
- Check the output for the binding error.
Expected behavior
The column "a,b0" display all values.
Actual behavior
Empty cells under the column "a,b0".
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Labels
No labels