More in this section

Forums / Developing with Sitefinity / Fliter DownloadList by code.

Fliter DownloadList by code.

3 posts, 0 answered
  1. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    18 Sep 2009
    Link to this post
    Hi.

    i try to Filter the Repeter on the DownloadList.ascx directly on the code. like

     

    <

     

    script runat="server">

     

     

     

     

     

     

    protected void Page_Load(object sender, EventArgs e)

     

    {

     

    LibraryManager manager =

    new LibraryManager('Libraries');

     

     

     

    if (!IsPostBack)

     

    {

     

     

    IMetaSearchInfo[] filters = new IMetaSearchInfo[2];

     

    filters[0] =

    new MetaSearchInfo(MetaValueTypes.ShortText,"ParentID", "(1a77afca-206c-46cd-b72a-ca0dacb531f8) ");

     

    filters[1] =

    new MetaSearchInfo(MetaValueTypes.ShortText, "Membre", HttpContext.Current.User.Identity.Name);

     

     

    IList newsList;

     

    newsList = manager.Content.GetContent(

    "Publication_Date DESC", filters);

     

    repeater.DataSource = newsList;

    repeater.DataBind();

    }

    }

     

     

     

    </

     

    script>

    Member is a curtom fields on the library and it contain a user.

    But it's dosen't work ? .

    Thk's

    Cyril

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Sep 2009
    Link to this post
    Hi Cyril Wasem,

    Here are some notes:

    - new LibraryManager('Libraries');  - you should use string, not single brackets.
    -  MetaSearchInfo[] filters = new IMetaSearchInfo[2];- this declaration is wrong.
     - "(1a77afca-206c-46cd-b72a-ca0dacb531f8) " I suppose this should be without brackets.

    Below is a sample code:

                 var manager = new LibraryManager("Libraries"); 
                List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>();  
                filter.Add(new MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "F1""V1")); 
                filter.Add(new MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "F2""V2")); 
                IList filteredList = manager.GetContent(string.Empty, filter.ToArray()); 
                repeater.DataSource = filteredList; 
                repeater.DataBind(); 

    You can use ContentFilterBuilder instead.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    18 Sep 2009
    Link to this post
    Hi,

    it's work fine.

    thk's
Register for webinar
3 posts, 0 answered