This code example shows how a BizForm record can be deleted.
[C#]
using CMS.FormEngine; using CMS.SettingsProvider; using CMS.DataEngine; using CMS.GlobalHelper;
...
string bizFormName = "TestingSiteContactUs"; string siteName = "CMSTestingSite";
// Get BizForm definition BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormName, siteName);
if (bfi != null) { // Get data type definition DataClassInfo dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID); if (dci != null) { // Get all bizform data GeneralConnection genConn = ConnectionHelper.GetConnection(); DataSet ds = genConn.ExecuteQuery(dci.ClassName + ".selectall", null, null, null);
if (!DataHelper.DataSourceIsEmpty(ds)) { // Get ID of the first record int formRecordID = ValidationHelper.GetInteger(ds.Tables[0].Rows[0][0], 0); // Get the record with specified ID DataClass formRecord = new DataClass(dci.ClassName, formRecordID, genConn);
if (!formRecord.IsEmpty()) { // Delete the first record. formRecord.Delete();
// Update number of entries in BizFormInfo bfi.FormItems--; BizFormInfoProvider.SetBizFormInfo(bfi);
lblInfo.Text = "The record was deleted successfully."; } } else { lblInfo.Text = "No data found."; } } } |
Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_bizforms_deleting_a_record.htm