PaymentsDueEntityDataSource.ContextTypeName = "Bills.DAL.BillsEntities";
PaymentsDueEntityDataSource.EnableFlattening = false;
PaymentsDueEntityDataSource.EntitySetName = "tblPayments_Due";
PaymentsDueEntityDataSource.Where = "it.UserName = " + HttpContext.Current.User.Identity.Name.ToString();
PaymentsDueEntityDataSource.Incl开发者_如何学Cude = "tblType, tblRepeat";
PaymentsDueEntityDataSource.EnableUpdate = true;
When I delete the Where clause, my gridview returns all records. When I hardcode the same string which is generated from the HttpContexxt string in the HTML, my gridview returns the proper records. However, when I try to use the code above, I get an out of scope message:
'kwingat' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly. Near simple identifier, line 6, column 15.
Any Ideas?
I think you need to pass it as a parameter
PaymentsDueEntityDataSource.Where = "it.UserName = @UserID";
PaymentsDueEntityDataSource.WhereParameters.Add(new Parameter("UserID", TypeCode.Int32, + HttpContext.Current.User.Identity.Name.ToString()));
精彩评论