Exemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the Copy button control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnCopy_Click(object sender, EventArgs e)
        {
            // Create a new Data View using the current item as a template.
            var id = int.Parse(hfDataViewId.Value);

            var dataViewService = new DataViewService(new RockContext());

            var newItem = dataViewService.GetNewFromTemplate(id);

            if (newItem == null)
            {
                return;
            }

            newItem.Name += " (Copy)";

            // Reset the stored identifier for the active Data View.
            hfDataViewId.Value = "0";

            ShowEditDetails(newItem);
        }