Sorting strings as numerics in a DataView

  • Thread starter Thread starter Joe Rattz
  • Start date Start date
J

Joe Rattz

I have a DataSet that gets loaded from an XML file. I
then bind the DataSet to a DataGrid. I want to be able to
sort on some columns, but the columns contain numeric data
that is treated as strings. So for example the order
becomes 1,11,2,22,3,33 instead of 1,2,3,11,22,33. Is
there someway I can set the Sort on the DataView to get a
numeric sort? Any other way to accomplish this?

Thanks.
 
Is the type of the column in the DataTable also string? If it is you might
want to try to changing it to numeric.
 
I am not sure how you mean this. My original data comes from a loosely typed XML file where everything is a string. But, do you mean for me to get access the System.Data.DataTable that is in my DataSet and change the type of the column in question to a numeric type? If so, I tried this after loading the XML and I get the following error

"Cannot change DataType of a column once it has data.

And, I can't change the type before I load the data because it does not exist


----- Teemu Keiski wrote: ----

Is the type of the column in the DataTable also string? If it is you migh
want to try to changing it to numeric
 

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