Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
 
Dataview Sorting is not applied to the following code.
dvSpeed.sort="Service_speed ASC";
the datatype is Integer for the Column Service_speed.
Posted 13-Apr-11 22:10pm
Edited 13-Apr-11 22:38pm
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I have Tried this and its Working Fine
 

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

            dt = new DataTable();
            idCoulumn = new DataColumn("ID", Type.GetType("System.Int32"));
            nameCoulumn = new DataColumn("Name", Type.GetType("System.String"));
            Description = new DataColumn("Description",Type.GetType("System.String"));
 
            dt.Columns.Add(idCoulumn);
            dt.Columns.Add(nameCoulumn);
            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";
 
  Permalink  
Comments
Dalek Dave at 14-Apr-11 3:38am
   
Good Answer.
mahen25 at 14-Apr-11 3:40am
   
Thanks
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Is Service_spee the Dataview column name as well.
Maybe the column name is different from this value.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

IF you're using a DataGrid to display the result, you must include this after sorting.
 
gridView.DataSource = dvSpeed;
gridView.DataBind();
  Permalink  
Comments
Vinodh.B at 14-Apr-11 3:18am
   
No i just want to do some calulations after sorting but Sorting itself not done
Pong D. Panda at 14-Apr-11 3:20am
   
if you can post the other code, it will help.
Vinodh.B at 14-Apr-11 3:23am
   
Dataview dvSpeed= dtSpeedAndFeed.DefaultView;
dvspeed.sort="Service_Speed ASC";
Now when i check dvspeed its not sorted .
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

The following code gave the Solution
 
Dataview dvSpeed=new dataview(dtSpeedAndFeed);
 
Thanks all for the response .
  Permalink  
Comments
mahen25 at 14-Apr-11 3:45am
   
You need to accept solution if it works fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 195
3 DamithSL 195
4 Richard MacCutchan 178
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 14 Feb 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100