"Mone Hsieh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi all
>
> I have a dataset which has column with comma in its name.
>
> How do I use DataView to sort it properly? The DataView.Sort always break
> the line when it sees a comma. Then it complains about field name being
> invalid. I've tried quoting my field name with '"' or ''' but they all
fail
> the same way.
>
> any idea how to make it work?
>
> Mone
Short of suggesting to not have column names with commas, I would do
something like this:
As far as I know, the Sort property will not support column names with
commas. It won't let you escape the comma. So instead, you can add an
expression column to the source table. If you are trying to sort on a
column named "Foo,Bar", then you could do this:
myTable.Columns.Add( "FooBarCopy",
custTable.Columns["Foo,Bar"].DataType, "[Foo,Bar]" );
This creates a column that uses the Expression property to reference to
the data in the original column. Now you can sort on the new column:
myView.Sort = "FooBarCopy";
Erik
|