.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ADO.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to sort DataTable?

Posted By: Ramesh     Posted Date: November 15, 2009    Points:2   Category :ADO.Net
Hi,

How to sort datatable in asp.net. I have a DataTable and the data is bind from SQL Server and inned to sort the datatable.

Regards
Ramesh

Responses
Author: vikas             
Posted Date: November 15, 2009     Points: 5   

Hello..
u can use sql Query OrderBy
Select * from TableName OrderBy CloumnName Desc/Asc

Author: Akhil Raj       [Moderator]      
Posted Date: November 17, 2009     Points: 5   
Author: Hirendra Sisodiya             
Posted Date: November 19, 2009     Points: 5   

hello
you can try :
Dim dt As New DataTable
dt.DefaultView.Sort = "ColName"
'Columns are sorted asending by default
'if you want to sort in descending order than you can try :
dt.DefaultView.Sort = "ColName DESC"

thanks



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend