locked
filter records by identity/user RRS feed

  • Question

  • User-2087919080 posted

    I am setting up dynamic data website according to Joe's dynamic data video tutorials in www.asp.net ........I can't figure out and I'm not experienced enough to know better how to set up a filter or whatever it takes to only show records for the logged in user...I think it takes a column in a table of the records I want to retrive, but I don't know how to code the event....

    also.....see a previous post I have about this.....I'm just narrowing it down as much as I can....thanks

    http://forums.asp.net/t/1363300.aspx

    Saturday, December 20, 2008 5:46 PM

Answers

  • User-330204900 posted

    I have two articles on my blog depending on whether you are using DD with Linq to SQL or Entity Framework?

    This one for the Entity Framework (EF) bits DynamicData - Automatic Column Update For Entity Framework

    And this one for Linq to SQL (L2S)

    DynamicData - Automatic Column Update

    And this one for adding filtering to the page. 

    DynamicData - Limit the Filter Fields

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 22, 2008 9:19 AM
  • User-330204900 posted

    well here's one (in good old Blue Peter tradition) that I prepared earlier I just ran it up and tested it so it's good [:D]

    UserFilter.zip

    Give that a go and let me know if its ok.

    P.S. it's in SQL Server 2008 Express [:(]

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 22, 2008 1:02 PM
  • User-330204900 posted

    If your running SQL Server 2008 the you still have a prerelease on you system, I know as I was in the same position until recenly [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 28, 2008 7:15 PM

All replies

  • User-330204900 posted

    I have two articles on my blog depending on whether you are using DD with Linq to SQL or Entity Framework?

    This one for the Entity Framework (EF) bits DynamicData - Automatic Column Update For Entity Framework

    And this one for Linq to SQL (L2S)

    DynamicData - Automatic Column Update

    And this one for adding filtering to the page. 

    DynamicData - Limit the Filter Fields

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 22, 2008 9:19 AM
  • User-2087919080 posted

    That should probably help, but the drawback is it is a above my head...I'll look more closely at it and try to make sense of it....for I'm just a little ol' bean counter trying to add some sophistication to my existence.

    thanks

    Monday, December 22, 2008 10:49 AM
  • User-330204900 posted

    Let me know what you are using (Linq to SQL or Entity Framework) and I'll post you working example if you like. [:D]

    Monday, December 22, 2008 10:54 AM
  • User-2087919080 posted

    MSLinqToSQLGenerator

    Monday, December 22, 2008 11:42 AM
  • User-330204900 posted

    I've never looked at that but I asume it will generate Linq to SQL dbml files etc. So I post a sample in a day or so [:D]

    Monday, December 22, 2008 12:48 PM
  • User-330204900 posted

    well here's one (in good old Blue Peter tradition) that I prepared earlier I just ran it up and tested it so it's good [:D]

    UserFilter.zip

    Give that a go and let me know if its ok.

    P.S. it's in SQL Server 2008 Express [:(]

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 22, 2008 1:02 PM
  • User-2087919080 posted

    error that the database is version 655 and mine is 612.  Any quick fix to this?...Or send me the database specs and I'll reconstruct it....thanks

    Sunday, December 28, 2008 3:59 PM
  • User-330204900 posted

    If your running SQL Server 2008 the you still have a prerelease on you system, I know as I was in the same position until recenly [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 28, 2008 7:15 PM
  • User-2087919080 posted

    thanks for your help.  I have a couple of questions...

    1.  wouldn't happen to have it in VB, would you?

    2.  Where in the code does the user filtering take place?

     

    Monday, December 29, 2008 10:26 AM
  • User-2087919080 posted

    I am trying to filter records by userID....take a look at the changes I am trying to use below for the userID filter and see if you can offer anything....

    I get stuck at the line....GridDataSource.WhereParameters.Add(parameter(currentUserID);

     

    public partial class List : System.Web.UI.Page

    {

    protected MetaTable table;protected void Page_Init(object sender, EventArgs e)

    {

    DynamicDataManager1.RegisterControl(GridView1,
    true /*setSelectionFromUrl*/);

    }

    protected void Page_Load(object sender, EventArgs e)

    {

    table = GridDataSource.GetTable();

    Title = table.DisplayName;

    InsertHyperLink.NavigateUrl = table.GetActionPath(
    PageAction.Insert);

    // Disable various options if the table is readonly

    if (table.IsReadOnly)

    {

    GridView1.Columns.RemoveAt(0);

    InsertHyperLink.Visible =
    false;

    }

    {

    MembershipUser currentUser = Membership.GetUser();Guid currentUserID = (Guid)currentUser.ProviderUserKey;

    GridDataSource.WhereParameters.Add(parameter(currentUserID);

    }

    }

    protected void OnFilterSelectedIndexChanged(object sender, EventArgs e)

    {

    GridView1.PageIndex = 0;

    }

    }

    Monday, December 29, 2008 11:52 AM
  • User-330204900 posted

    Over the next couple of days I will try to know up a VB version and test it [:D]

    Monday, December 29, 2008 12:52 PM
  • User-2087919080 posted

    Another thing I'd like to ask....Why are you using Created By (UserName) to filter records instead of UserID?  Is there some advantage to this?

    Monday, December 29, 2008 2:27 PM
  • User-330204900 posted

    Quick and dirty code [:D], it's just for demo. Someone asks a question and I build a solution tending to concetrate of whats easyest to understand (well hopefully) [:D]

    [;)]

    Monday, December 29, 2008 3:44 PM