?
Solved

Dataview sort

Posted on 2014-02-06
4
Medium Priority
?
457 Views
Last Modified: 2014-02-06
Hi,

How can i sort my column(dv.Row.Item("Time")) in dataview so the output would be sorted like this (Note where the dots are is just continues numbers going up)

0
1
2
3
4
5
6
7
8
9
..........
43
44
45
HT
46
47
48
49
..........
87
88
89
90
FT

Dim DvTheData As New DataView(scorestable)
        'loop through them all and show them
        For Each dv As DataRowView In DvTheData

	test.Text += dv.Row.Item("Time") & " " & dv.Row.Item("Score") &  "<br>"

        Next

Open in new window

0
Comment
Question by:runnerjp2005
[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
  • 2
4 Comments
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 39838525
hi.. you can use sort function like this..
private DataTable getsortedtable(DataTable dt)
 {
    dataview v=dt.defaultview;
    v.sort="columnName DESC";
    dt=v.toTable();
    return dt;
  }

or make a code like this example

DataTable dt = null;
            DataRow dr = null;
 
            DataColumn idCoulumn = null;
            DataColumn nameCoulumn = null;
            DataColumn Description  = null;
            //int i = 0;

            dt = new DataTable();
            id = new DataColumn("ID", Type.GetType("System.Int32"));
            name = new DataColumn("Name", Type.GetType("System.String"));
            Description = new DataColumn("Description",Type.GetType("System.String"));
 
            dt.Columns.Add(id);
            dt.Columns.Add(name);
            dt.Columns.Add(Description);
 
            dr = dt.NewRow();
            dr["ID"] = 1;
            dr["Name"] = "Name1";
            dr["Description"]="Good";
            dt.Rows.Add(dr);
 
            dr = dt.NewRow();
            dr["ID"] = 2;
            dr["Name"] = "Name2";
            dr["Description"] = "VeryGood";
            dt.Rows.Add(dr);
            DataView dv = new DataView(dt);
            dv.Sort = "ID DESC";
0
 

Author Comment

by:runnerjp2005
ID: 39838538
Hi thanks but the issue is between the numbers 45 & 46 is the letters HT - also after 90 is FT
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 39838559
You can keep an integer column with 1 to 90, sort it and then insert HT and FT afterwards.
0
 

Author Closing Comment

by:runnerjp2005
ID: 39838601
That would do it!

thanks :)
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

719 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