I have a linq query that creates an anonymous type. I order the linq according to a dynamic setting. I then convert this to a list. When I bind this to a gridview, the ordering is lost. What am I doing wrong? Here is some code:
Public Function GetContacts(ByVal sortExpression As String) As IEnumerable
Dim contactsQuery = From con In context.Contacts
Join cus In context.Customers
On con.customerID Equals cus.customerID
Select con.contactTel1,
con.customerContactID,
con.contactTel2,
con.contactEmail,
con.contactName,
cus.customerName,
cus.customerID
Order By sortExpression
'The follow returns the list, but the sortExpression is ignored
Return contactsQuery.ToList
...
Go to the complete details ...