More in this section

Forums / Developing with Sitefinity / Filter News Categories 3.7 sp3

Filter News Categories 3.7 sp3

4 posts, 0 answered
  1. Stuart
    Stuart avatar
    9 posts
    18 Jul 2007
    05 May 2010
    Link to this post
    When a user is editing or adding a news article, we want to limit the categories that appear in the drop down list.

    We have created roles like   IS - xxxxx  and categories   IS - xxxxxx

    If the user is a member of the role IS - XXXXX,  then the source code below will display all of the categories IS - xxxxx

    I have that part working, but when I save the changes, the NewsItemEdit.ascx page does not accept the category from the new list.

    In Short> I am not sure how to get the new category list on the NewsItemEdit.ascx page and how the save button should accept the new list.

    NewsItemEdit.ascx code behind
    protected void Page_Load(object sender, EventArgs e)
        NewsManager newsManager = new NewsManager("News");
        IList listOfCategories = newsManager.Content.GetCategories(0,100,"CategoryName ASC");
        if (listOfCategories.Count > 0)
            foreach (ICategory catItem in listOfCategories)
                   // used to get in front part of their role example: IS - Editor
                   // should be IS.
    string preRole = catItem.CategoryName;
                int divider = preRole.IndexOf("-");
            if (divider >= 0)
                preRole = preRole.Substring(0, divider).Trim();

               // if user is in the role of IS Approver, add the category.
    if (UserManager.GetCurrentUser().IsInRole(preRole + " Approver") || UserManager.GetCurrentUser().IsInRole(preRole + " Editor"))
                categoriesList.Items.Add(catItem.CategoryName );

    My changed NewsItemEdit.ascx page has ...
    <asp:DropDownList ID="categoriesList" runat="server" />

    The unchanged NewsItemEdit.ascx page has the following...


    <asp:Label ID="Label8" AssociatedControlID="Category" runat="server">
    <asp:Literal ID="Literal16" runat="server" Text="<%$Resources:Category %>" />
    <em id="Em1" runat="server"></em></asp:Label>
    <sf:ContentCategoriesField ID="Category" runat="server" />
  2. Leonard
    Leonard avatar
    19 posts
    01 Dec 2005
    06 May 2010
    Link to this post
    Hi Greg,

    Change the ID of your new drop-down list control to "Category" so that it can be matched with the related meta-field.

    I hope it helps --
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    06 May 2010
    Link to this post
    Hi Leonard,

    You could map CategoriesField.ascx external templates ( How to map a template) and there is declaration of the RadComboBox control. In the code behind of the template you could subscribe for the ItemDataBound event of the RadComboBox and remove/add some items.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  4. Stuart
    Stuart avatar
    9 posts
    18 Jul 2007
    06 May 2010
    Link to this post
    When I change the drop down list to Category, I get an error.

    I got ivan Dimitrov, suggestion to work.

Register for webinar
4 posts, 0 answered