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.

Re: Sorting strings as numerics in a DataView by Teemu

Teemu
Tue Nov 11 04:53:44 CST 2003

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

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Joe Rattz" <joe_rattz@genpt.com> wrote in message
news:032101c3a7bd$3a691a90$a101280a@phx.gbl...
> 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.



Re: Sorting strings as numerics in a DataView by anonymous

anonymous
Tue Nov 11 09:41:07 CST 2003

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