Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sort Datatable IPAddress column

Posted on 2014-07-31
6
Medium Priority
?
596 Views
Last Modified: 2014-08-05
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.
0
Comment
Question by:Basicfarmer
  • 4
6 Comments
 
LVL 21

Expert Comment

by:Randy Poole
ID: 40232288
can you supply a sample xml file as well as the code you are currently trying
0
 

Author Comment

by:Basicfarmer
ID: 40232311
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
 
LVL 27

Expert Comment

by:Shaun Kline
ID: 40232328
You can you an ICompare Interface to handle this specialized sort: http://msdn.microsoft.com/en-us/library/ms171608(v=vs.90).aspx
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

Author Comment

by:Basicfarmer
ID: 40232435
I cant use the comparer because the datagridview is data bound. I need to sort the data table.
0
 

Accepted Solution

by:
Basicfarmer earned 0 total points
ID: 40233256
I found out that i could use a dataView to sort.
0
 

Author Closing Comment

by:Basicfarmer
ID: 40240765
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
The viewer will learn how to implement Singleton Design Pattern in Java.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question