in program (asp.net, c#) using gridview show data. gets data following query. select * nametable nameid in (4,3,1,22,15,8,9,5,7) but problem gridview showing data in ascending sort order of nameid (1,3,4,5,7,8,9,15,22) . dont want data sorted, should show way mentioned in query (4,3,1,22,15,8,9,5,7) here code private void loadgridview() { query = "select * nametable 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(); } that pretty difficult code you've provided. doesn't have gridview , it's how data returned sql. sql won't order results way. you'd have specify explicit case in order by this: query = "select * nametable nameid in (4,3,1,22,15,8,9,5,7) " + "order case nameid when 4 0 " + "when 3 1 " +