简体   繁体   English

带有GridView WHERE说明的EntityDataSource

[英]EntityDataSource with a GridView WHERE Explnation

Hi I use a GridView with an EntityDataSource. 嗨,我将GridView与EntityDataSource一起使用。

I need to FILTER data from EntityDataSource using WHERE. 我需要使用WHERE从EntityDataSource过滤数据。 The Filter should use the ProviderUserKey (GUID DataType in my case) for the Current logged in User. 筛选器应为当前登录用户使用ProviderUserKey(在我的情况下为GUID数据类型)。

At the moment I use to retrive my Guid this code in Page_Load Event 目前,我习惯在Page_Load事件中检索此代码

Guid myActiveUser = (Guid)Membership.GetUser().ProviderUserKey;
  • How to pass this variable to EntityDataSource "Where" for filtering and siplay the result in my GridView? 如何将此变量传递给EntityDataSource“在哪里”以过滤并在GridView中显示结果?
  • It is this the right way to do it? 这是正确的方法吗? Any other solution? 还有其他解决方案吗?

Thanks guys! 多谢你们!

Try using the code like the following: 尝试使用如下代码:

Guid myActiveUser = (Guid)Membership.GetUser().ProviderUserKey;    
EntityDataSource1.Where = "it.User = " + myActiveUser.ToString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM