More in this section

Forums / Developing with Sitefinity / Filtering data dynamic data

Filtering data dynamic data

3 posts, 1 answered
  1. David
    David avatar
    38 posts
    Registered:
    05 Apr 2012
    13 Aug 2012
    Link to this post
    Hi

    I am trying to retrieve a list of module contents and filter on a specific field.

    The code I currently have which appears to pull all the published items back looks like this.

    01.DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
    02.                Type mclEventType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.McLEvents.MclEvent");
    03. 
    04.                var theitems =
    05.                    dynamicModuleManager.GetDataItems(mclEventType).Where(
    06.                        s => s.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);
    07.                 
    08.                grdFuture.DataSource = theitems;
    09.                grdFuture.DataBind();

    I think I need to add another where clause to the expression, but I can't seem to. 

    Any suggestions gratefully received.

    David Bigg
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    16 Aug 2012
    Link to this post
    Hello,

    To filter based on a certain field use GetValue  followed by the field name you want to get. To use GetValue() add reference to Telerik.Sitefinity.Model.
    using Telerik.Sitefinity.Model;
     
    DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
                    Type mclEventType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.McLEvents.MclEvent");
      
                    var theitems =
                        dynamicModuleManager.GetDataItems(mclEventType).Where(
                            s => s.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && s.GetValue("Title") == "Item1");
                      
                    grdFuture.DataSource = theitems;
                    grdFuture.DataBind();
                    


    Greetings,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. David
    David avatar
    38 posts
    Registered:
    05 Apr 2012
    16 Aug 2012
    Link to this post
    Hi Stanislav

    Thanks for your reply, that was exactly what I needed. It is all filtering nicely now.

    Regards,
    David Bigg
3 posts, 1 answered