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.
BasicfarmerAsked:
Who is Participating?
 
BasicfarmerAuthor Commented:
I found out that i could use a dataView to sort.
0
 
Randy PooleCommented:
can you supply a sample xml file as well as the code you are currently trying
0
 
BasicfarmerAuthor Commented:
I have deleted most of the things i previously tried but this was the last thing i did.

ds.Tables(0).DefaultView.Sort = "IPADDRESS DESC"
Printers.xml
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Shaun KlineLead Software EngineerCommented:
You can you an ICompare Interface to handle this specialized sort: http://msdn.microsoft.com/en-us/library/ms171608(v=vs.90).aspx
0
 
BasicfarmerAuthor Commented:
I cant use the comparer because the datagridview is data bound. I need to sort the data table.
0
 
BasicfarmerAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.