Member_2_5230414
asked on
Dataview sort
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
How can i sort my column(dv.Row.Item("Time")
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
ASKER
Hi thanks but the issue is between the numbers 45 & 46 is the letters HT - also after 90 is FT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That would do it!
thanks :)
thanks :)
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.Strin
Description = new DataColumn("Description",T
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";