Deleting multiple data entries from a Form

   —   
By default, you are only able to delete a Form's entries one by one. This article describes how to add a simple delete button to the editing interface to delete selected items at once.
The changes will be made to the administration interface in CMSDesk -> Tools -> Forms -> <edit a form> -> Data.  You need to make changes to three files.
The first file to modify is \CMSModules\Bizforms\Tools\BizForm_Edit_Data.aspx. You can add a delete button within the <asp:Content > tags:
<asp:Button Text="Delete" id="btnDelete" runat="server" OnClick="Delete_Click" />

The second file is the code behind \CMSModules\Bizforms\Tools\BizForm_Edit_Data.aspx.cs. Copy and paste the code below into this file:
   
    protected void Delete_Click(object sender, EventArgs e)
    {
        DataView dv = (DataView)this.gridData.GridView.DataSource;

        int count = 1;

        string formid = "0";

        if (Request.QueryString["formid"] != null)
        {
            formid = Request.QueryString["formid"];
        }

        CMS.FormEngine.BizFormInfo bfi = CMS.FormEngine.BizFormInfoProvider.GetBizFormInfo(System.Convert.ToInt32(formid));

        foreach (DataRow item in dv.Table.Rows)
        {
            if (gridData.SelectedItems.Contains(count.ToString()))
            {
                int entryID = System.Convert.ToInt32(item[0]);
                CMS.FormEngine.BizFormItem bfii = new BizFormItem(item, CMS.SettingsProvider.DataClassInfoProvider.GetClassName(bfi.FormClassID));                bfii.Delete();
            }
            count++;
        }

        gridData.ReloadData();
    }


The last file to modify is the file \CMSModules\Bizforms\Tools\BizForm_Edit_Data.xml. There you have to add the key below:

<key name="ShowSelection" value="true" />

Please note, that this is only an example and it is not fully tested for all scenarios.
-bp-


See also: UniGrid configuration

Applies to: Kentico CMS 6.0
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.