Try Now
More in this section

Forums / General Discussions / Batch edit and delete for news items

Batch edit and delete for news items

2 posts, 0 answered
  1. Szymon
    Szymon avatar
    22 posts
    04 Jan 2008
    29 Jun 2009
    Link to this post
    I'm updating a website deployed last year for an anual event. I wanted to preserve the same structure, layout and some content for upcoming edition so I statrted from previous year's database. But there are some other things like news that I would like to delete (alternatively I would like to set the Expired date on all of them at once). Is there a way to do a batch updated/delete on all items? I'm bit worried about doing this direclty on the database.

    Szymon Kobalczyk
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    25 Oct 2016
    29 Jun 2009
    Link to this post
    Hello Szymon,

    You can use Sitefinity API instead of working with the database.

    I prepared a user control that will delete all news items for "News" provider.

    Control template:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="DeleteAllNews.ascx.cs" Inherits="CustomControls_DeleteAllNews" %> 
    <asp:Button ID="button1" runat="server" Text="DeleteAllNews"  
        onclick="button1_Click" /> 

    Code behind:

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using Telerik.News; 
    using System.Collections; 
    using Telerik.Cms.Engine; 
    public partial class CustomControls_DeleteAllNews : System.Web.UI.UserControl 
        protected void Page_Load(object sender, EventArgs e) 
        protected void button1_Click(object sender, EventArgs e) 
            NewsManager manager = new NewsManager("News"); 
            IList listofItems = manager.Content.GetContent(); 
            for (int i = 0; i < listofItems.Count; i++) 
                IContent cnt = (IContent)listofItems[i]; 

    Useful articles - Modules API Overview. If you need further assistance, please let us know.

    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered