Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sort Datatable IPAddress column

Posted on 2014-07-31
6
525 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 26

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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

809 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