Solved

Sort Datatable IPAddress column

Posted on 2014-07-31
6
494 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 25

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to go to Web page 2 50
Please explain: Aspect Oriented Programming 2 51
Code enhancement 5 12
VB.NET HttpWebRequest 12 30
This article will show, step by step, how to integrate R code into a R Sweave document
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now