Solved

Dataview sort

Posted on 2014-02-06
4
452 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Calendar Control 5 53
asp.net repeater 2 35
Updating Printer Details in VB.Net 16 42
Display Day name if condition is true in crystal report (VB.Net) 2 35
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

732 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