Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Error: Instance property 'DateTime' is not defined for type 'GRIDVIEWSORT.LoginInfo'

$
0
0

I am getting this below error when i try to sort the asp.net gridview

Error: Instance property 'DateTime' is not defined for type 'GRIDVIEWSORT.LoginInfo'

Code:

private List<LoginInfo> Sort(string sortColumn, string sortDirection)

{
IQueryable<LoginInfo> query = list.AsQueryable();
var param = Expression.Parameter(typeof(LoginInfo));
var mySortExpression = Expression.Lambda<Func<LoginInfo, object>>(Expression.Convert(Expression.Property(param, sortColumn), typeof(object)), param);
if (sortDirection == "Ascending")
{
query = query.OrderBy(mySortExpression);
}
else
{
query = query.OrderByDescending(mySortExpression);
}
return query.ToList();
}

Object:

public class LoginInfo
{
public string Id { get; set; }
public DateTime Date { get; set; }
public DateTime Time { get; set; }
public string Result { get; set; }
}


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>