Reputation: 1950
Here is my EntityDatasource:
<asp:EntityDataSource ID="edsUsers" runat="server"
ConnectionString="name=kdEntities" DefaultContainerName="kdEntities" EnableDelete="True"
EnableFlattening="False" EnableInsert="True" EnableUpdate="True"
EntitySetName="Users" AutoGenerateWhereClause="true">
<WhereParameters>
<asp:SessionParameter Name="UsrID" SessionField="UsrID" DefaultValue="-1" Type="Int32" />
</WhereParameters>
I would assume I need to use the OnSelecting event of the EntityDatasource, but I haven't figured out how to check the parameter value.
I want to cancel the query if the value is -1, but I would prefer to check through the datasource and not the Session field the parameter uses.
Thanks Kevin
Upvotes: 0
Views: 272
Reputation: 948
You may think of adding a Custom Parameter of type Object. That can hopefully solve your problem.
<WhereParameters>
<cmsParameter:CustomParameter Name="UsrID" />
</WhereParameters>
Then you can add a new Custom Parameter Class like
public class CustomParameter : Parameter
{
protected override object Eval(HttpContext context, Control control)
{
MembershipUser cur_User = Membership.GetUser();
return cur_User.ProviderUserKey;
}
}
This actually gets assigned to "UsrID" custom parameter we have specified.
Upvotes: 1