privatevoid CreateReportCategory() { // Create new report category object ReportCategoryInfo newCategory = newReportCategoryInfo(); // Set the properties newCategory.CategoryDisplayName = "My new category"; newCategory.CategoryCodeName = "MyNewCategory"; // Save the report category ReportCategoryInfoProvider.SetReportCategoryInfo(newCategory); }
The following example gets and updates a report category.
privatebool GetAndUpdateReportCategory() {
// Get the report category ReportCategoryInfo updateCategory = ReportCategoryInfoProvider.GetReportCategoryInfo("MyNewCategory");
if (updateCategory != null) {
// Update the properties updateCategory.CategoryDisplayName = updateCategory.CategoryDisplayName.ToLower();
// Save the changes ReportCategoryInfoProvider.SetReportCategoryInfo(updateCategory); returntrue; } returnfalse; }
The following example gets and bulk updates report categories.
privatebool GetAndBulkUpdateReportCategories() { // Prepare the parameters string where = "CategoryCodeName LIKE N'MyNewCategory%'"; // Get the data DataSet categories = ReportCategoryInfoProvider.GetCategories(where, null); if (!DataHelper.DataSourceIsEmpty(categories)) { // Loop through the individual items foreach (DataRow categoryDr in categories.Tables[0].Rows) {
// Create object from DataRow ReportCategoryInfo modifyCategory = newReportCategoryInfo(categoryDr); // Update the properties modifyCategory.CategoryDisplayName = modifyCategory.CategoryDisplayName.ToUpper();
// Save the changes ReportCategoryInfoProvider.SetReportCategoryInfo(modifyCategory); } returntrue; } returnfalse; }
The following example deletes a report category.
privatebool DeleteReportCategory() {
// Get the report category ReportCategoryInfo deleteCategory = ReportCategoryInfoProvider.GetReportCategoryInfo("MyNewCategory");