Sort DataView according to Integer

  • Thread starter Thread starter jez
  • Start date Start date
J

jez

So I have a listBox whose datasource is a DataView.

I sort the DataView according to a sequenceNumber. Each entry has a
different sequenceNumber. For example : 1,2,3,4,8,9,11,12,14,22,35 etc...

The big problem is that DataView seems to convert this sequenceNumber (which
by the way is an integer) into a string before using it to sort the
DataView. So here's what I get :

1,11,12,14,2,22,3,35,4,8,9 etc... So yeh - really not what I'm expecting...
Could anyone please confirm that I'm nuts and that DataView can sort
integers in a normal civilized way?:P

thanks heaps!

jez
 
Sounds like its string for the column datatype but you've confirmed that
it's Int in the local datatable not just the db right?. Anyway, I just
wrote this up quickly where the DataTable was unsorted...works fine. Can
you post the code you're using?
Dim dt As New DataTable

Dim dv As DataView

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

da.Fill(dt)

dv = dt.DefaultView

DataGrid1.DataSource = dv

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

dv.Sort = "Department"

End Sub


--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
 
this is the code that I use for the DataView :

DataView listBoxCustomersDataView = new DataView();
listBoxCustomersDataView.Table = customersTable;
listBoxCustomersDataView.RowFilter = "showOnList=true";
listBoxCustomersDataView.Sort = "sequenceNumber";
listBoxCustomersDataView.RowStateFilter = DataViewRowState.CurrentRows;

I then bind my ListBox to the DataView as such :

listBoxCustomers.DataSource = listBoxCustomersDataView;
listBoxCustomers.DisplayMember = "name";
listBoxCustomers.ValueMember = "customerID";

The DataSet uses an XSD schema, in the XSD schema the sequenceNumber type is
'integer' - I also tried 'int'. By the way, I don't use a DB, I get the data
from an xml file (if that's of any help).
 
Jez,

DataView does not convert integers to strings to do sorting.
If column is sorted as string, it is considered a string.
You can print out column's DataType.Name to see the column's type.

It might be string because:
- Column type is incorrect in the schema.
- Schema was not loaded to this particular DataSet, inference was used.
- Schema was not loaded successfully and exception was ignored, inference
was used.

Make sure your XSD schema is correct and make sure it was loaded correctly
into this specific DataSet.
Please let me know if it helped.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
Hey Jez:

It shouldn't matter where the data comes from, the real issue is the current
type and it sounds like you're ok there. I've done this every way I know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it wouldn't
change the order. I'm guessing that although DisplayMember and ValueMember
are different fields altogether from sequenceNumber, you've verified that
those numbers are the way it's sorting, sequenceNumber vs. customerId. Just
for giggles, would you mind verifyting the DataTypes of each of the columns
pramatically? customerTable.Columns["sequenceNumber"].DataType; just to
make sure it's int. It should be but that behavior is totally consistent
with string types.

The other thing is that you may want to create an expression colum that
equals sequenceID, but throw in a Convert as the expression. This shouldn't
be necessary, but I've tried it a few different ways and can't replicate the
problem.
 
Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the schema is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like the type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If so what
am I doing wrong ? Here's the code I use to read the xml file and the xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

William Ryan eMVP said:
Hey Jez:

It shouldn't matter where the data comes from, the real issue is the current
type and it sounds like you're ok there. I've done this every way I know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it wouldn't
change the order. I'm guessing that although DisplayMember and ValueMember
are different fields altogether from sequenceNumber, you've verified that
those numbers are the way it's sorting, sequenceNumber vs. customerId. Just
for giggles, would you mind verifyting the DataTypes of each of the columns
pramatically? customerTable.Columns["sequenceNumber"].DataType; just to
make sure it's int. It should be but that behavior is totally consistent
with string types.

The other thing is that you may want to create an expression colum that
equals sequenceID, but throw in a Convert as the expression. This shouldn't
be necessary, but I've tried it a few different ways and can't replicate the
problem.


jez said:
this is the code that I use for the DataView :

DataView listBoxCustomersDataView = new DataView();
listBoxCustomersDataView.Table = customersTable;
listBoxCustomersDataView.RowFilter = "showOnList=true";
listBoxCustomersDataView.Sort = "sequenceNumber";
listBoxCustomersDataView.RowStateFilter = DataViewRowState.CurrentRows;

I then bind my ListBox to the DataView as such :

listBoxCustomers.DataSource = listBoxCustomersDataView;
listBoxCustomers.DisplayMember = "name";
listBoxCustomers.ValueMember = "customerID";

The DataSet uses an XSD schema, in the XSD schema the sequenceNumber
type
is
'integer' - I also tried 'int'. By the way, I don't use a DB, I get the data
from an xml file (if that's of any help).
 
If you have a separate schema file, it has to be loaded first.



If you load data first, schema (data can not be stored without schema) will
be inferred and all type information will be lost.

Loading schema after data will not change column types since it's not
possible once column is created.

Schema from file will be mostly ignored in that case.



Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.





jez said:
Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the schema is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like the type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If so what
am I doing wrong ? Here's the code I use to read the xml file and the xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

William Ryan eMVP said:
Hey Jez:

It shouldn't matter where the data comes from, the real issue is the current
type and it sounds like you're ok there. I've done this every way I know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it wouldn't
change the order. I'm guessing that although DisplayMember and ValueMember
are different fields altogether from sequenceNumber, you've verified that
those numbers are the way it's sorting, sequenceNumber vs. customerId. Just
for giggles, would you mind verifyting the DataTypes of each of the columns
pramatically? customerTable.Columns["sequenceNumber"].DataType; just to
make sure it's int. It should be but that behavior is totally consistent
with string types.

The other thing is that you may want to create an expression colum that
equals sequenceID, but throw in a Convert as the expression. This shouldn't
be necessary, but I've tried it a few different ways and can't replicate the
problem.


jez said:
this is the code that I use for the DataView :

DataView listBoxCustomersDataView = new DataView();
listBoxCustomersDataView.Table = customersTable;
listBoxCustomersDataView.RowFilter = "showOnList=true";
listBoxCustomersDataView.Sort = "sequenceNumber";
listBoxCustomersDataView.RowStateFilter = DataViewRowState.CurrentRows;

I then bind my ListBox to the DataView as such :

listBoxCustomers.DataSource = listBoxCustomersDataView;
listBoxCustomers.DisplayMember = "name";
listBoxCustomers.ValueMember = "customerID";

The DataSet uses an XSD schema, in the XSD schema the sequenceNumber
type
is
'integer' - I also tried 'int'. By the way, I don't use a DB, I get
the
data
from an xml file (if that's of any help).



Sounds like its string for the column datatype but you've
confirmed
that
it's Int in the local datatable not just the db right?. Anyway, I just
wrote this up quickly where the DataTable was unsorted...works fine. Can
you post the code you're using?
Dim dt As New DataTable

Dim dv As DataView

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

da.Fill(dt)

dv = dt.DefaultView

DataGrid1.DataSource = dv

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

dv.Sort = "Department"

End Sub


--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
So I have a listBox whose datasource is a DataView.

I sort the DataView according to a sequenceNumber. Each entry has a
different sequenceNumber. For example : 1,2,3,4,8,9,11,12,14,22,35
etc...

The big problem is that DataView seems to convert this sequenceNumber
(which
by the way is an integer) into a string before using it to sort the
DataView. So here's what I get :

1,11,12,14,2,22,3,35,4,8,9 etc... So yeh - really not what I'm
expecting...
Could anyone please confirm that I'm nuts and that DataView can sort
integers in a normal civilized way?:P

thanks heaps!

jez
 
Thanks for that! It seems to be working fine now! The problem was that I
first loaded the data and then loaed the XML Schema from an XSD file.

However, when the XSD was loading up correctly (sequenceNumber type is
Int32) data was not loaded at all (but I didn't get an error message
either!) - I tried changing a couple of things in the schema but still
didn't work. So I ended up using a programmatically defined schema which did
solve my problem.

It's all good now, I'm just not too happy about the fact that I can't use an
XSD schema and the fact that I don't have a primary key in one of my
productsTable (using the programmatically defined schema). Here's the code
for the XSD schema... thanks again to both of you !

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="customersTable" msdata:IsDataSet="false">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="customerID" type="xs:int" />
<xs:attribute name="customerEmail" type="xs:string" />
<xs:attribute name="sequenceNumber" type="xs:integer" />
<xs:attribute name="reasonCode" type="xs:string" />
<xs:attribute name="showOnList" type="xs:boolean" />
<xs:attribute name="orderNumber" type="xs:string" />
<xs:attribute name="ndd" type="xs:string" />
<xs:attribute name="customerComments" type="xs:string" />
<xs:attribute name="customerDelivered" type="xs:boolean" />
<xs:attribute name="customerTelephone" type="xs:string" />
<xs:attribute name="customerCity" type="xs:string" />
<xs:attribute name="customerZip" type="xs:string" />
<xs:attribute name="customerStreet" type="xs:string" />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="customersTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:key>
</xs:element>
<xs:element name="productsTable" msdata:IsDataSet="false">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="customerID" type="xs:int" />
<xs:attribute name="orderNumber" type="xs:string" />
<xs:attribute name="retQty" type="xs:int" />
<xs:attribute name="delQty" type="xs:int" />
<xs:attribute name="product" type="xs:string" />
<xs:attribute name="productID" type="xs:string" />
</xs:complexType>
<xs:key name="productsTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:key>
<xs:keyref name="customersTableproductsTable" refer="customersTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:keyref>
</xs:element>
</xs:schema>


Ilya Tumanov said:
If you have a separate schema file, it has to be loaded first.



If you load data first, schema (data can not be stored without schema) will
be inferred and all type information will be lost.

Loading schema after data will not change column types since it's not
possible once column is created.

Schema from file will be mostly ignored in that case.



Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.





jez said:
Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the schema is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like the type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If so what
am I doing wrong ? Here's the code I use to read the xml file and the xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

William Ryan eMVP said:
Hey Jez:

It shouldn't matter where the data comes from, the real issue is the current
type and it sounds like you're ok there. I've done this every way I know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it wouldn't
change the order. I'm guessing that although DisplayMember and ValueMember
are different fields altogether from sequenceNumber, you've verified that
those numbers are the way it's sorting, sequenceNumber vs. customerId. Just
for giggles, would you mind verifyting the DataTypes of each of the columns
pramatically? customerTable.Columns["sequenceNumber"].DataType; just to
make sure it's int. It should be but that behavior is totally consistent
with string types.

The other thing is that you may want to create an expression colum that
equals sequenceID, but throw in a Convert as the expression. This shouldn't
be necessary, but I've tried it a few different ways and can't
replicate
the
problem.


this is the code that I use for the DataView :

DataView listBoxCustomersDataView = new DataView();
listBoxCustomersDataView.Table = customersTable;
listBoxCustomersDataView.RowFilter = "showOnList=true";
listBoxCustomersDataView.Sort = "sequenceNumber";
listBoxCustomersDataView.RowStateFilter = DataViewRowState.CurrentRows;

I then bind my ListBox to the DataView as such :

listBoxCustomers.DataSource = listBoxCustomersDataView;
listBoxCustomers.DisplayMember = "name";
listBoxCustomers.ValueMember = "customerID";

The DataSet uses an XSD schema, in the XSD schema the sequenceNumber type
is
'integer' - I also tried 'int'. By the way, I don't use a DB, I get the
data
from an xml file (if that's of any help).



Sounds like its string for the column datatype but you've confirmed
that
it's Int in the local datatable not just the db right?. Anyway, I just
wrote this up quickly where the DataTable was unsorted...works fine.
Can
you post the code you're using?
Dim dt As New DataTable

Dim dv As DataView

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

da.Fill(dt)

dv = dt.DefaultView

DataGrid1.DataSource = dv

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

dv.Sort = "Department"

End Sub


--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
So I have a listBox whose datasource is a DataView.

I sort the DataView according to a sequenceNumber. Each entry
has
 
Thanks for that! It seems to be working fine now! The problem was that I
first loaded the data and then loaed the XML Schema from an XSD file.

However, when the XSD was loading up correctly (sequenceNumber type is
Int32) data was not loaded at all (but I didn't get an error message
either!) - I tried changing a couple of things in the schema but still
didn't work. So I ended up using a programmatically defined schema which did
solve my problem.

It's all good now, I'm just not too happy about the fact that I can't use an
XSD schema and the fact that I don't have a primary key in one of my
productsTable (using the programmatically defined schema). Here's the code
for the XSD schema... Maybe I have to change the targetNamespace for the
data to load up ? thanks again to both of you !

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="customersTable" msdata:IsDataSet="false">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="customerID" type="xs:int" />
<xs:attribute name="customerEmail" type="xs:string" />
<xs:attribute name="sequenceNumber" type="xs:integer" />
<xs:attribute name="reasonCode" type="xs:string" />
<xs:attribute name="showOnList" type="xs:boolean" />
<xs:attribute name="orderNumber" type="xs:string" />
<xs:attribute name="ndd" type="xs:string" />
<xs:attribute name="customerComments" type="xs:string" />
<xs:attribute name="customerDelivered" type="xs:boolean" />
<xs:attribute name="customerTelephone" type="xs:string" />
<xs:attribute name="customerCity" type="xs:string" />
<xs:attribute name="customerZip" type="xs:string" />
<xs:attribute name="customerStreet" type="xs:string" />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="customersTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:key>
</xs:element>
<xs:element name="productsTable" msdata:IsDataSet="false">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="customerID" type="xs:int" />
<xs:attribute name="orderNumber" type="xs:string" />
<xs:attribute name="retQty" type="xs:int" />
<xs:attribute name="delQty" type="xs:int" />
<xs:attribute name="product" type="xs:string" />
<xs:attribute name="productID" type="xs:string" />
</xs:complexType>
<xs:key name="productsTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:key>
<xs:keyref name="customersTableproductsTable" refer="customersTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:keyref>
</xs:element>
</xs:schema>


Ilya Tumanov said:
If you have a separate schema file, it has to be loaded first.



If you load data first, schema (data can not be stored without schema) will
be inferred and all type information will be lost.

Loading schema after data will not change column types since it's not
possible once column is created.

Schema from file will be mostly ignored in that case.



Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.





jez said:
Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the schema is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like the type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If so what
am I doing wrong ? Here's the code I use to read the xml file and the xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

William Ryan eMVP said:
Hey Jez:

It shouldn't matter where the data comes from, the real issue is the current
type and it sounds like you're ok there. I've done this every way I know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it wouldn't
change the order. I'm guessing that although DisplayMember and ValueMember
are different fields altogether from sequenceNumber, you've verified that
those numbers are the way it's sorting, sequenceNumber vs. customerId. Just
for giggles, would you mind verifyting the DataTypes of each of the columns
pramatically? customerTable.Columns["sequenceNumber"].DataType; just to
make sure it's int. It should be but that behavior is totally consistent
with string types.

The other thing is that you may want to create an expression colum that
equals sequenceID, but throw in a Convert as the expression. This shouldn't
be necessary, but I've tried it a few different ways and can't
replicate
the
problem.


this is the code that I use for the DataView :

DataView listBoxCustomersDataView = new DataView();
listBoxCustomersDataView.Table = customersTable;
listBoxCustomersDataView.RowFilter = "showOnList=true";
listBoxCustomersDataView.Sort = "sequenceNumber";
listBoxCustomersDataView.RowStateFilter = DataViewRowState.CurrentRows;

I then bind my ListBox to the DataView as such :

listBoxCustomers.DataSource = listBoxCustomersDataView;
listBoxCustomers.DisplayMember = "name";
listBoxCustomers.ValueMember = "customerID";

The DataSet uses an XSD schema, in the XSD schema the sequenceNumber type
is
'integer' - I also tried 'int'. By the way, I don't use a DB, I get the
data
from an xml file (if that's of any help).



Sounds like its string for the column datatype but you've confirmed
that
it's Int in the local datatable not just the db right?. Anyway, I just
wrote this up quickly where the DataTable was unsorted...works fine.
Can
you post the code you're using?
Dim dt As New DataTable

Dim dv As DataView

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

da.Fill(dt)

dv = dt.DefaultView

DataGrid1.DataSource = dv

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

dv.Sort = "Department"

End Sub


--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
So I have a listBox whose datasource is a DataView.

I sort the DataView according to a sequenceNumber. Each entry
has


Ilya Tumanov said:
If you have a separate schema file, it has to be loaded first.



If you load data first, schema (data can not be stored without schema) will
be inferred and all type information will be lost.

Loading schema after data will not change column types since it's not
possible once column is created.

Schema from file will be mostly ignored in that case.



Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.





jez said:
Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the schema is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like the type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If so what
am I doing wrong ? Here's the code I use to read the xml file and the xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

William Ryan eMVP said:
Hey Jez:

It shouldn't matter where the data comes from, the real issue is the current
type and it sounds like you're ok there. I've done this every way I know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it wouldn't
change the order. I'm guessing that although DisplayMember and ValueMember
are different fields altogether from sequenceNumber, you've verified that
those numbers are the way it's sorting, sequenceNumber vs. customerId. Just
for giggles, would you mind verifyting the DataTypes of each of the columns
pramatically? customerTable.Columns["sequenceNumber"].DataType; just to
make sure it's int. It should be but that behavior is totally consistent
with string types.

The other thing is that you may want to create an expression colum that
equals sequenceID, but throw in a Convert as the expression. This shouldn't
be necessary, but I've tried it a few different ways and can't
replicate
the
problem.


this is the code that I use for the DataView :

DataView listBoxCustomersDataView = new DataView();
listBoxCustomersDataView.Table = customersTable;
listBoxCustomersDataView.RowFilter = "showOnList=true";
listBoxCustomersDataView.Sort = "sequenceNumber";
listBoxCustomersDataView.RowStateFilter = DataViewRowState.CurrentRows;

I then bind my ListBox to the DataView as such :

listBoxCustomers.DataSource = listBoxCustomersDataView;
listBoxCustomers.DisplayMember = "name";
listBoxCustomers.ValueMember = "customerID";

The DataSet uses an XSD schema, in the XSD schema the sequenceNumber type
is
'integer' - I also tried 'int'. By the way, I don't use a DB, I get the
data
from an xml file (if that's of any help).



Sounds like its string for the column datatype but you've confirmed
that
it's Int in the local datatable not just the db right?. Anyway, I just
wrote this up quickly where the DataTable was unsorted...works fine.
Can
you post the code you're using?
Dim dt As New DataTable

Dim dv As DataView

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

da.Fill(dt)

dv = dt.DefaultView

DataGrid1.DataSource = dv

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

dv.Sort = "Department"

End Sub


--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
So I have a listBox whose datasource is a DataView.

I sort the DataView according to a sequenceNumber. Each entry
has
 
If you have schema in the DataSet, only matching elements of data file will
be loaded.
Mismatched data will be ignored. I'm pretty sure it's the case.

You should redo the schema so it matches data.

Since you have data already and it's probably fixed, you can use inference
on this data.
That can be done by creating simple desktop program which reads XML and
saves the schema.
Next, you can edit this schema to change data types. You can also add keys
and relations as needed in the XDS designer.

Or, you can save you programmatically created schema if it works and use
it.
By the way, you can create keys and relations programmatically if you need
them.

Finally, if data source is in your control, you can create schema in the
designer from scratch and add matching data later.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "jez" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
References: <[email protected]>
<[email protected]>
<[email protected]>
<#[email protected]>
Subject: Re: Sort DataView according to Integer
Date: Fri, 4 Jun 2004 13:12:05 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Lines: 483
Message-ID: <[email protected]>
Organization: Tiscali bv
NNTP-Posting-Date: 04 Jun 2004 13:12:07 CEST
NNTP-Posting-Host: 213.177.151.7
X-Trace: 1086347527 dreader2.news.tiscali.nl 41760 213.177.151.7:4684
X-Complaints-To: (e-mail address removed)
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA06.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08
phx.gbl!newsfeed00.sul.t-online.de!t-online.de!irazu.switch.ch!switch.ch!ne
wsfeed1.ip.tiscali.net!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscal
i.nl!not-for-mail
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:54534
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Thanks for that! It seems to be working fine now! The problem was that I
first loaded the data and then loaed the XML Schema from an XSD file.

However, when the XSD was loading up correctly (sequenceNumber type is
Int32) data was not loaded at all (but I didn't get an error message
either!) - I tried changing a couple of things in the schema but still
didn't work. So I ended up using a programmatically defined schema which did
solve my problem.

It's all good now, I'm just not too happy about the fact that I can't use an
XSD schema and the fact that I don't have a primary key in one of my
productsTable (using the programmatically defined schema). Here's the code
for the XSD schema... Maybe I have to change the targetNamespace for the
data to load up ? thanks again to both of you !

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="customersTable" msdata:IsDataSet="false">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="customerID" type="xs:int" />
<xs:attribute name="customerEmail" type="xs:string" />
<xs:attribute name="sequenceNumber" type="xs:integer" />
<xs:attribute name="reasonCode" type="xs:string" />
<xs:attribute name="showOnList" type="xs:boolean" />
<xs:attribute name="orderNumber" type="xs:string" />
<xs:attribute name="ndd" type="xs:string" />
<xs:attribute name="customerComments" type="xs:string" />
<xs:attribute name="customerDelivered" type="xs:boolean" />
<xs:attribute name="customerTelephone" type="xs:string" />
<xs:attribute name="customerCity" type="xs:string" />
<xs:attribute name="customerZip" type="xs:string" />
<xs:attribute name="customerStreet" type="xs:string" />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="customersTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:key>
</xs:element>
<xs:element name="productsTable" msdata:IsDataSet="false">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="customerID" type="xs:int" />
<xs:attribute name="orderNumber" type="xs:string" />
<xs:attribute name="retQty" type="xs:int" />
<xs:attribute name="delQty" type="xs:int" />
<xs:attribute name="product" type="xs:string" />
<xs:attribute name="productID" type="xs:string" />
</xs:complexType>
<xs:key name="productsTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:key>
<xs:keyref name="customersTableproductsTable" refer="customersTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:keyref>
</xs:element>
</xs:schema>


Ilya Tumanov said:
If you have a separate schema file, it has to be loaded first.



If you load data first, schema (data can not be stored without schema) will
be inferred and all type information will be lost.

Loading schema after data will not change column types since it's not
possible once column is created.

Schema from file will be mostly ignored in that case.



Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.





jez said:
Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the schema is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like
the
type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If
so
what
am I doing wrong ? Here's the code I use to read the xml file and the xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

Hey Jez:

It shouldn't matter where the data comes from, the real issue is the
current
type and it sounds like you're ok there. I've done this every way I know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it wouldn't
change the order. I'm guessing that although DisplayMember and
ValueMember
are different fields altogether from sequenceNumber, you've verified that
those numbers are the way it's sorting, sequenceNumber vs. customerId.
Just
for giggles, would you mind verifyting the DataTypes of each of the
columns
pramatically? customerTable.Columns["sequenceNumber"].DataType;
just
to get
the has sort
the can
sort


Ilya Tumanov said:
If you have a separate schema file, it has to be loaded first.



If you load data first, schema (data can not be stored without schema) will
be inferred and all type information will be lost.

Loading schema after data will not change column types since it's not
possible once column is created.

Schema from file will be mostly ignored in that case.



Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.





jez said:
Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the schema is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like
the
type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If
so
what
am I doing wrong ? Here's the code I use to read the xml file and the xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

Hey Jez:

It shouldn't matter where the data comes from, the real issue is the
current
type and it sounds like you're ok there. I've done this every way I know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it wouldn't
change the order. I'm guessing that although DisplayMember and
ValueMember
are different fields altogether from sequenceNumber, you've verified that
those numbers are the way it's sorting, sequenceNumber vs. customerId.
Just
for giggles, would you mind verifyting the DataTypes of each of the
columns
pramatically? customerTable.Columns["sequenceNumber"].DataType;
just
to get
the has sort
the can
sort
 
Ilya,

thanks again for the post. Sorry for the late reply, got caught up in some
other problems:/

I'm interested for future reference.. is there then any way to create an xml
file and from that xml file create a schema ? (is that what is called
inference ?). That would probably be the easiest way out..

jez

"Ilya Tumanov [MS]" said:
If you have schema in the DataSet, only matching elements of data file will
be loaded.
Mismatched data will be ignored. I'm pretty sure it's the case.

You should redo the schema so it matches data.

Since you have data already and it's probably fixed, you can use inference
on this data.
That can be done by creating simple desktop program which reads XML and
saves the schema.
Next, you can edit this schema to change data types. You can also add keys
and relations as needed in the XDS designer.

Or, you can save you programmatically created schema if it works and use
it.
By the way, you can create keys and relations programmatically if you need
them.

Finally, if data source is in your control, you can create schema in the
designer from scratch and add matching data later.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.<[email protected]>
<[email protected]>
<#[email protected]>
Subject: Re: Sort DataView according to Integer
Date: Fri, 4 Jun 2004 13:12:05 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Lines: 483
Message-ID: <[email protected]>
Organization: Tiscali bv
NNTP-Posting-Date: 04 Jun 2004 13:12:07 CEST
NNTP-Posting-Host: 213.177.151.7
X-Trace: 1086347527 dreader2.news.tiscali.nl 41760 213.177.151.7:4684
X-Complaints-To: (e-mail address removed)
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA06.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08phx.gbl!newsfeed00.sul.t-online.de!t-online.de!irazu.switch.ch!switch.ch!newsfeed1.ip.tiscali.net!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscal
i.nl!not-for-mail
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:54534
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Thanks for that! It seems to be working fine now! The problem was that I
first loaded the data and then loaed the XML Schema from an XSD file.

However, when the XSD was loading up correctly (sequenceNumber type is
Int32) data was not loaded at all (but I didn't get an error message
either!) - I tried changing a couple of things in the schema but still
didn't work. So I ended up using a programmatically defined schema which did
solve my problem.

It's all good now, I'm just not too happy about the fact that I can't
use
an
XSD schema and the fact that I don't have a primary key in one of my
productsTable (using the programmatically defined schema). Here's the code
for the XSD schema... Maybe I have to change the targetNamespace for the
data to load up ? thanks again to both of you !

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="customersTable" msdata:IsDataSet="false">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="customerID" type="xs:int" />
<xs:attribute name="customerEmail" type="xs:string" />
<xs:attribute name="sequenceNumber" type="xs:integer" />
<xs:attribute name="reasonCode" type="xs:string" />
<xs:attribute name="showOnList" type="xs:boolean" />
<xs:attribute name="orderNumber" type="xs:string" />
<xs:attribute name="ndd" type="xs:string" />
<xs:attribute name="customerComments" type="xs:string" />
<xs:attribute name="customerDelivered" type="xs:boolean" />
<xs:attribute name="customerTelephone" type="xs:string" />
<xs:attribute name="customerCity" type="xs:string" />
<xs:attribute name="customerZip" type="xs:string" />
<xs:attribute name="customerStreet" type="xs:string" />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="customersTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:key>
</xs:element>
<xs:element name="productsTable" msdata:IsDataSet="false">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="customerID" type="xs:int" />
<xs:attribute name="orderNumber" type="xs:string" />
<xs:attribute name="retQty" type="xs:int" />
<xs:attribute name="delQty" type="xs:int" />
<xs:attribute name="product" type="xs:string" />
<xs:attribute name="productID" type="xs:string" />
</xs:complexType>
<xs:key name="productsTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:key>
<xs:keyref name="customersTableproductsTable" refer="customersTableKey1">
<xs:selector xpath="." />
<xs:field xpath="@orderNumber" />
</xs:keyref>
</xs:element>
</xs:schema>


Ilya Tumanov said:
If you have a separate schema file, it has to be loaded first.



If you load data first, schema (data can not be stored without schema) will
be inferred and all type information will be lost.

Loading schema after data will not change column types since it's not
possible once column is created.

Schema from file will be mostly ignored in that case.



Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.





Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the
schema
is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like the
type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If so
what
am I doing wrong ? Here's the code I use to read the xml file and
the
xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

Hey Jez:

It shouldn't matter where the data comes from, the real issue is the
current
type and it sounds like you're ok there. I've done this every way I
know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it
wouldn't
change the order. I'm guessing that although DisplayMember and
ValueMember
are different fields altogether from sequenceNumber, you've verified
that
those numbers are the way it's sorting, sequenceNumber vs. customerId.
Just
for giggles, would you mind verifyting the DataTypes of each of the
columns
pramatically? customerTable.Columns["sequenceNumber"].DataType;
just
to
make sure it's int. It should be but that behavior is totally
consistent
with string types.

The other thing is that you may want to create an expression
colum
that
equals sequenceID, but throw in a Convert as the expression. This
shouldn't
be necessary, but I've tried it a few different ways and can't replicate
the
problem.


this is the code that I use for the DataView :

DataView listBoxCustomersDataView = new DataView();
listBoxCustomersDataView.Table = customersTable;
listBoxCustomersDataView.RowFilter = "showOnList=true";
listBoxCustomersDataView.Sort = "sequenceNumber";
listBoxCustomersDataView.RowStateFilter =
DataViewRowState.CurrentRows;

I then bind my ListBox to the DataView as such :

listBoxCustomers.DataSource = listBoxCustomersDataView;
listBoxCustomers.DisplayMember = "name";
listBoxCustomers.ValueMember = "customerID";

The DataSet uses an XSD schema, in the XSD schema the sequenceNumber
type
is
'integer' - I also tried 'int'. By the way, I don't use a DB, I get
the
data
from an xml file (if that's of any help).



Sounds like its string for the column datatype but you've
confirmed
that
it's Int in the local datatable not just the db right?. Anyway, I
just
wrote this up quickly where the DataTable was unsorted...works fine.
Can
you post the code you're using?
Dim dt As New DataTable

Dim dv As DataView

Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e
As
System.EventArgs) Handles Button1.Click

da.Fill(dt)

dv = dt.DefaultView

DataGrid1.DataSource = dv

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e
As
System.EventArgs) Handles Button2.Click

dv.Sort = "Department"

End Sub


--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
So I have a listBox whose datasource is a DataView.

I sort the DataView according to a sequenceNumber. Each
entry
has
a
different sequenceNumber. For example : 1,2,3,4,8,9,11,12,14,22,35
etc...

The big problem is that DataView seems to convert this
sequenceNumber
(which
by the way is an integer) into a string before using it to sort
the
DataView. So here's what I get :

1,11,12,14,2,22,3,35,4,8,9 etc... So yeh - really not what I'm
expecting...
Could anyone please confirm that I'm nuts and that DataView can
sort
integers in a normal civilized way?:P

thanks heaps!

jez


Ilya Tumanov said:
If you have a separate schema file, it has to be loaded first.



If you load data first, schema (data can not be stored without schema) will
be inferred and all type information will be lost.

Loading schema after data will not change column types since it's not
possible once column is created.

Schema from file will be mostly ignored in that case.



Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.





Ryan, Ilya, thanks to both for the reply!

So I have tested the type and I guess you were both right.. the
schema
is
not properly loaded. The type is string for sequenceNumber. For a boolean
that I use in my application the type is also string. It seems like the
type
for each field is string. I do think that the XSD file is loaded to some
extent though because I first read an XML file to populate a DataSet and
then I 'read' the XSD schema and get no error. Is that possible ? If so
what
am I doing wrong ? Here's the code I use to read the xml file and
the
xsd
schema. I first read the xml and then load the xsd :

_CustomersDS.ReadXml(getFullPath() + @"\deliveryfile.xml");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

//import relations schema
_CustomersDS.ReadXmlSchema(getFullPath() + @"\schema.xsd");
_CustomersDS.Namespace = "myNameSpace";
_CustomersDS.DataSetName = "_CustomersDS";

thanks!

Hey Jez:

It shouldn't matter where the data comes from, the real issue is the
current
type and it sounds like you're ok there. I've done this every way I
know
how . The only two things I can see is if the RowFilter criteria was
filtering stuff out, but that would make stuff appear or not, it
wouldn't
change the order. I'm guessing that although DisplayMember and
ValueMember
are different fields altogether from sequenceNumber, you've verified
that
those numbers are the way it's sorting, sequenceNumber vs. customerId.
Just
for giggles, would you mind verifyting the DataTypes of each of the
columns
pramatically? customerTable.Columns["sequenceNumber"].DataType;
just
to
make sure it's int. It should be but that behavior is totally
consistent
with string types.

The other thing is that you may want to create an expression
colum
that
equals sequenceID, but throw in a Convert as the expression. This
shouldn't
be necessary, but I've tried it a few different ways and can't replicate
the
problem.


this is the code that I use for the DataView :

DataView listBoxCustomersDataView = new DataView();
listBoxCustomersDataView.Table = customersTable;
listBoxCustomersDataView.RowFilter = "showOnList=true";
listBoxCustomersDataView.Sort = "sequenceNumber";
listBoxCustomersDataView.RowStateFilter =
DataViewRowState.CurrentRows;

I then bind my ListBox to the DataView as such :

listBoxCustomers.DataSource = listBoxCustomersDataView;
listBoxCustomers.DisplayMember = "name";
listBoxCustomers.ValueMember = "customerID";

The DataSet uses an XSD schema, in the XSD schema the sequenceNumber
type
is
'integer' - I also tried 'int'. By the way, I don't use a DB, I get
the
data
from an xml file (if that's of any help).



Sounds like its string for the column datatype but you've
confirmed
that
it's Int in the local datatable not just the db right?. Anyway, I
just
wrote this up quickly where the DataTable was unsorted...works fine.
Can
you post the code you're using?
Dim dt As New DataTable

Dim dv As DataView

Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e
As
System.EventArgs) Handles Button1.Click

da.Fill(dt)

dv = dt.DefaultView

DataGrid1.DataSource = dv

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e
As
System.EventArgs) Handles Button2.Click

dv.Sort = "Department"

End Sub


--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
So I have a listBox whose datasource is a DataView.

I sort the DataView according to a sequenceNumber. Each
entry
has
a
different sequenceNumber. For example : 1,2,3,4,8,9,11,12,14,22,35
etc...

The big problem is that DataView seems to convert this
sequenceNumber
(which
by the way is an integer) into a string before using it to sort
the
DataView. So here's what I get :

1,11,12,14,2,22,3,35,4,8,9 etc... So yeh - really not what I'm
expecting...
Could anyone please confirm that I'm nuts and that DataView can
sort
integers in a normal civilized way?:P

thanks heaps!

jez
 
Back
Top