// assign the product to a new category protected void assignButton_Click(object sender, EventArgs e) { // Check if a category was selected if (categoriesListAssign.SelectedIndex != -1) { // Get the category ID that was selected in the DropDownList string categoryId = categoriesListAssign.SelectedItem.Value; // Assign the product to the category bool success = CatalogBLO.AssignProductToCategory(currentProductId, categoryId); // Display status message statusLabel.Text = success ? "Product assigned successfully" : "Product assignation failed"; // Refresh the page PopulateControls(); } else { statusLabel.Text = "You need to select a category"; } }