From: Anthony on
I parsed a xml file to a DataGrid.
Now i'd like to sort a column with numeric values.

I figured out that everything is sorted as a string value.
How can i sort this column as a numeric value.
Found some examples with Google, but nothing works for me.

Anthony.


From: Martin Honnen on
Anthony wrote:
> I parsed a xml file to a DataGrid.
> Now i'd like to sort a column with numeric values.
>
> I figured out that everything is sorted as a string value.
> How can i sort this column as a numeric value.

Are you using a DataSet and ReadXml()?
The right approach is to define an XML schema that defines the right
numeric type you want, then use ReadXmlSchema() on the DataSet before
you load the XML instance document with the ReadXml() method.

--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
From: Patrice on
Hi,

This is likely because they are still strings. Not sure how you parse the
file but it would be best to expose each column under its expected type
(dates, integers, booleans or whatever). Here it seems to me that you just
expose all values as strings...

How do you bind this XML file to your datagrid ?

--
Patrice



"Anthony" <Anthony(a)anti.spam.com> a �crit dans le message de
news:eMSRayK2KHA.4580(a)TK2MSFTNGP05.phx.gbl...
>I parsed a xml file to a DataGrid.
> Now i'd like to sort a column with numeric values.
>
> I figured out that everything is sorted as a string value.
> How can i sort this column as a numeric value.
> Found some examples with Google, but nothing works for me.
>
> Anthony.
>

From: Patrice on
> This is likely because they are still strings. Not sure how you parse the
> file but it would be best to expose each column under its expected type
> (dates, integers, booleans or whatever). Here it seems to me that you just
> expose all values as strings...

You should have a "XML To Schema" item in VS that will infer a schema from
your XML file. Then you'll be able to tweak the schema if needed and to use
this schema when loading the XML file so that its data are exposed with the
type they should have...

--
Patrice

From: Anthony on
XmlDataDocument xmlDatadoc = new XmlDataDocument();
xmlDatadoc.DataSet.ReadXml(@"d:\myxmlfile.xml");
DataSet ds = new DataSet("books");
ds = xmlDatadoc.DataSet;
dataGridView1.DataSource = ds.DefaultViewManager;
dataGridView1.DataMember = "title";

Anthony



 |  Next  |  Last
Pages: 1 2 3
Prev: Strange Tooltip Problem
Next: MSIL code