Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4230890
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:54:43+00:00 2026-05-21T01:54:43+00:00

I use EF 4, C# and MS Membership Provider. I have a GridView with

  • 0

I use EF 4, C# and MS Membership Provider.

I have a GridView with DataSource an EntityDataSource web control.

I would like filter Data using EntityDataSource, filter show apply for the Current Logged-In User, this value should be taken using MS Memebership Provider ( Membership.GetUser(); ).

Now I cannot inf any Parameter in EntityDataSource that would allow me to dot that (in Where/Automatically generate a Where expression using provided parameter ).

Do you have any ideas?

Please provide me a sample of code. Thanks for your time!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T01:54:44+00:00Added an answer on May 21, 2026 at 1:54 am

    You cannot bind the user’s identity declaratively in markup directly to the EntityDataSource. But there are basically two workarounds:

    The first is the easier one but requires code-behind. You can use a generic asp:Parameter and set its value in code-behind to the user’s identity:

    Markup:

    <asp:EntityDataSource ID="MyEntityDataSource" runat="server" 
        ConnectionString="name=MyContext" 
        DefaultContainerName="MyContext" 
        EntitySetName="MyObjectSet" 
        AutoGenerateWhereClause="False"
        Where="it.Username = @Username" 
        <WhereParameters>
            <asp:Parameter Name="Username" Type="String" />
        </WhereParameters>
    </asp:EntityDataSource>
    

    Code-behind:

    protected void Page_Load(object sender, EventArgs e)
    {
        MyEntityDataSource.WhereParameters["Username"].DefaultValue =
            User.Identity.Name;
    }
    

    The second way is to create a custom parameter. An example how to do that is shown here. Note: The example is based on a asp:SqlDataSource but it should work as well for an EntityDataSource if you make sure that you use WhereParameters in the EntityDataSource instead of SelectParameters in the SqlDataSource.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to use the ASP.NET membership provider in the following (low-security) scenario... My
I have two web applications in the same solution. They both use different membership/profile
I'd like to use the default membership through EF. I will have pages displaying
I have encountered a very strange issue. Whenever I use the .NET membership provider
I develop an asp.net web application and I use ASP.NET membership provider. The application
I have .NET MVC 3 project where I use sql membership provider and entity
i want to use asp.net membership provider for my own database i have own
I have built two websites, both of them use a custom membership provider I
We have a couple of ASP.NET WebForms applications that use the ADAM Membership provider,
I have website that uses ASP.net Membership Provider. This web site will be served

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.