Linking to fields containing a period in a DataTable in C # / WPF

I have a SQL CE database that is out of my control, which has fields in the. Format, complete with a period in the column name. Columns will always be different, so I cannot have a strongly typed data field. I was instructed to display the data of a dynamic table in a DataGrid.

Usually it would be easy to automatically generate columns, and that's cool. A simple example.

However, I am not allowed to do this because "." the character in the column names destroys the binding.

I'm currently trying to add a translation layer to a dataset (you may have to maintain a dictionary with translations into.).

My question is , is there a better way ? I remembered something about the possibility of having a SourceColumnName in a DataTable, but I did not see it. There is an "Inscription", but I can not get attached to it ...

Any thoughts?

+2
source share
1 answer

Replace as an alternative . dot . dot on \u2024

If you ask this question to Microsoft users, they will tell you that this (your problem) is due to the fact that WPF DataGrid supports "matching property data" with a data source. For this reason . dot . dot trying to resolve the subobject contained in your DataTable.

In the next line, they will politely ask you to replace . dot . dot on _ Underscore in the column name.

(http://social.msdn.microsoft.com/Forums/en/wpf/thread/7d84c8f2-2709-4642-a259-739036ffd2a6)

But this is neither a solution nor an alternative.

The solution will be provided by them only by changing their coding.

For an alternative replacement. c \u2024 This is a unicode character for C / C ++ / Java

Read more about it here.

+3
source

Source: https://habr.com/ru/post/970934/


All Articles