Sorting strings as numerics in a DataView

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I haven't received any helpful response so I am reposting my question with all the messages. Please start with the bottom message and work your way up. Thanks

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
 
Hi Joe,

I am wondering whether you solve this problem, because I have the same
issue as you.

In my situation, I receive a xml file where one node is decimal or
empty. for example
<price>11</price>
<price>2</price>
<price>-5</price>
<price></price>

I can't find a way to generate a schema(.xsd) for this element to a
decimal type because of the empty node. So I leave it as string type in
..xsd file.

Then when I sort the dataview, it will be sorted by string type like:
" "(space here)
11
2
-5


Let me know if you have a solution for this, thanks in advance.

Hanson

Joe said:
I haven't received any helpful response so I am reposting my question
with all the messages. Please start with the bottom message and work
your way up. Thanks.
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:
 
Back
Top