/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAddSelectedAddons_Click(object sender, EventArgs e) { ProductAdmin AdminAccess = new ProductAdmin(); StringBuilder sb = new StringBuilder(); //Loop through the grid values foreach (GridViewRow row in uxGrid.Rows) { CheckBox check = (CheckBox)row.Cells[0].FindControl("chkProductHighlight") as CheckBox; //Get AddOnId int HighlighID = int.Parse(row.Cells[1].Text); int DisplayOrder = int.Parse(row.Cells[4].Text); string name = row.Cells[2].Text; if (check.Checked) { ProductHighlight entity = new ProductHighlight(); //Set Properties entity.ProductID = ItemId; entity.HighlightID = HighlighID; entity.DisplayOrder = DisplayOrder; if (!AdminAccess.IsHighlightExists(ItemId,HighlighID)) { AdminAccess.AddProductHighlight(entity); check.Checked = false; } else { sb.Append(name + ","); lblErrorMessage.Visible = true; } } } if (sb.ToString().Length > 0) { sb.Remove(sb.ToString().Length - 1, 1); //Display Error message lblErrorMessage.Text = "The following highlight(s) are already associated with this product.<br/>" + sb.ToString(); } else { Response.Redirect(ViewPageLink + "&itemid=" + ItemId); } }