Solved

Sort Datatable IPAddress column

Posted on 2014-07-31
6
565 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
[X]
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
  • 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
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.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

636 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