views:

163

answers:

0

I am trying to populate GridView, using EntityDataSource(code behind), I need to able to sort GridView. However when I sort i get error: A property with name 'aspnet_Users.UserId1' does not exist in metadata for entity type So I beleive it is because I generate where parameter in code behind:

ActiveEnqDataSource.WhereParameters.Add(new SessionParameter("aspnet_Users.UserId", TypeCode.Object, "UserName"));

Full code is :

ActiveEnqDataSource.ConnectionString = db.Connection.ConnectionString;
             ActiveEnqDataSource.DefaultContainerName = "Entities";
             ActiveEnqDataSource.EntitySetName = "Enquiries";
             ActiveEnqDataSource.Include = "UserCars.CarModel.CarMake, Category, aspnet_Users";

             ActiveEnqDataSource.EnableUpdate = true;
             ActiveEnqDataSource.EnableInsert = true;
             ActiveEnqDataSource.EnableDelete = true;
             ActiveEnqDataSource.AutoGenerateWhereClause = true;


             ActiveEnqDataSource.WhereParameters.Add(new SessionParameter("aspnet_Users.UserId", TypeCode.Object, "UserName"));

Any suggestions? Thank you very much! The gridview itself renders perfectly, only thing I cannot sort it, any "whereParameters" I add, Add 1 to the property e.g UserId1,EnquiryStatus1, ProdauctName1. etc...