How to preserve order in Gridview

esot3r1c

New Member
In my program (asp.net, C#) I am using a gridview to show data.it gets the data from the following query.\[code\]select * from Nametable where NameID in (4,3,1,22,15,8,9,5,7)\[/code\]But the problem is Gridview is showing the data in ascending sort order of NameID like \[code\](1,3,4,5,7,8,9,15,22)\[/code\].I dont want data to be sorted, it should showexactly the way I mentioned in the query like \[code\](4,3,1,22,15,8,9,5,7)\[/code\]Here is my code\[code\]private void loadGridView(){ Query = "select * from Nametable where NameID in (4,3,1,22,15,8,9,5,7)" DataSet ds = SqlHelper.ExecuteDataset(CommonSettings.Constring, CommandType.Text, Query); GridView1.DataSource = ds; GridView1.DataBind();}\[/code\]
 
Back
Top