How to keep order on object in collection(List<>) in .net 2.0
Posted on 2009-05-20
In a web method I am returning DataSet from Sql server SP. I am handling pagination and sorting at SP level. It works fine.
In c# code I am populating collection(List<>) of class objects by looping through the DataSet. Data is being added to collection in order it is coming from SP. But when Calling applications displays results(looping thru collections) the sort order gots messed up. It doesnt keep sort order we passed from SP.
My guess is it is happening because List<> doesnt keep order of element in which they gets added .Am I correct?
If Answer is yes Do I need to do sort again at resultSet level i.e Sorting of Collection. I am new to .net and would like to know what should be approch to handle sorting at response level if we have different sortFilters .