Basicfarmer
asked on
Sort Datatable IPAddress column
Experts, i have a datatable in a dataset that has an IP Address column. I set the datasource of my datagridview to ds.tables(0). The datatable is created by reading an xml file. ds.readxml(mypath.xml).
I want the user to be able to sort the IP Addresses either ascending or descending. But everything i have tried does not sort them properly. I know it is because they are a sequence of numbers in a text field. But I dont know how to get around it.
I want the user to be able to sort the IP Addresses either ascending or descending. But everything i have tried does not sort them properly. I know it is because they are a sequence of numbers in a text field. But I dont know how to get around it.
can you supply a sample xml file as well as the code you are currently trying
ASKER
I have deleted most of the things i previously tried but this was the last thing i did.
ds.Tables(0).DefaultView.S ort = "IPADDRESS DESC"
Printers.xml
ds.Tables(0).DefaultView.S
Printers.xml
You can you an ICompare Interface to handle this specialized sort: http://msdn.microsoft.com/en-us/library/ms171608(v=vs.90).aspx
ASKER
I cant use the comparer because the datagridview is data bound. I need to sort the data table.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
First expert asked for the file to be posted. I posted the file and there was no follow up.
Second expert clearly didn't read my post because I stated that I was using the dataTable as the dataSource for the DataGridView.
After much reading I figured out to use a dataView.
Second expert clearly didn't read my post because I stated that I was using the dataTable as the dataSource for the DataGridView.
After much reading I figured out to use a dataView.