Getting sort error on datagrid column name

  • Thread starter Thread starter nate axtell
  • Start date Start date
N

nate axtell

In VB .NET I load the contents of an Excel or comma seperated values file
into a dataGrid (via a datatable). One of the columns has a comma in the
name of the column. So for the comma separated values files I put double
quotes are the column name. What I see is that the name ends up getting
displayed correctly in the DataGrid column, "Class (1,2,3)". When I click
on the column to sort I see the following error:
"Additional information: [Class(1 isn't a valid Sort string entry"

Somehow the column name is being broken at the first comma. Is there a way
around this, does anyone know what's happening?
 
If you use a dataview you can sort columns.

i.e. dim dv as new dataview(your table)
dv.sort = "column1 ASC"

you can also sort more then one column:
dv.sort = "column1, column2 ASC"

As you see it is comma separated.
I think clicking on the columnheader does something simulair as above, so if
you have comma's in your columnname, it will be looking for columns that are
not there.
You could put the numbers in single quotes?

i.e. "Class '(1,2,3)' "

I think it will help, but I'm not sure.

rg.
Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top