Filtering a gridview based on userName

Discussion in '.NET' started by rofromtoronto2010, Apr 3, 2010.

  1. rofromtoronto2010

    rofromtoronto2010

    Joined:
    Apr 3, 2010
    Messages:
    2
    Likes Received:
    0
    Hi,

    I am using a gridview with ado.net entity framework. I am trying to filter my gridview records by userName equal to logged in user. But I don't know how to do this.


    In asp:EntityDataSource I should use the Where clause, have tried the following:

    <asp:EntityDataSource ID="DocumentsDataSource1" runat="server"
    ConnectionString="name=iWEntities1"
    DefaultContainerName="iWEntities1" EnableDelete="True"
    EnableInsert="True" EnableUpdate="True" EntitySetName="GeneratedDocument"
    EntityTypeFilter="GeneratedDocument"
    Where="it.UserId = '<% Context.User.Identity.Name %>' ">
    </asp:EntityDataSource>

    didnt work.. also looked at the availabe where parameters such as ProfileParameter, Cookie param, etc.. dont see anything that would allow for getting the logged in user though. Any idea how to do this?

    Thanks,
    - R
     
    rofromtoronto2010, Apr 3, 2010
    #1
    1. Advertisements

  2. rofromtoronto2010

    rofromtoronto2010

    Joined:
    Apr 3, 2010
    Messages:
    2
    Likes Received:
    0
    grid view filter by userid

    ah, got it.

    I created a custom param and referenced the assembly as follows:

    <WhereParameters>
    <iwc:UserIdParam Name="userID" Type="String" />
    </WhereParameters>
     
    rofromtoronto2010, Apr 4, 2010
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.