protected void lbUpdateSelected_Click(object sender, EventArgs e) { SaveLastViewedGroups(); // Convert to entity objects var overviewGroups = ChosenCustomLabelGroups; var groups = new List <ProductGoogleCustomLabelGroupMapping>(); foreach (var item in overviewGroups) { groups.Add(new ProductGoogleCustomLabelGroupMapping { ProductId = item.ProductId, CustomLabel1 = item.CustomLabel1, CustomLabel2 = item.CustomLabel2, CustomLabel3 = item.CustomLabel3, CustomLabel4 = item.CustomLabel4, CustomLabel5 = item.CustomLabel5, Value1 = item.Value1, Value2 = item.Value2, Value3 = item.Value3, Value4 = item.Value4, Value5 = item.Value5 }); } ProductService.SaveProductGoogleCustomLabelGroups(groups); enbNotice.Message = "Items were updated successfully"; ChosenCustomLabelGroups.Clear(); NotChosenCustomLabelGroups.Clear(); LoadGroups(); }
protected void gvCustomLabels_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var group = (ProductGoogleCustomLabelGroupMappingOverviewModel)e.Row.DataItem; ProductGoogleCustomLabelGroupMappingOverviewModel chosenGroup = null; if (ExistInChosenGroups(group)) { chosenGroup = ChosenCustomLabelGroups.Find(delegate(ProductGoogleCustomLabelGroupMappingOverviewModel item) { return(item.ProductId == group.ProductId); }); } CheckBox cb = e.Row.FindControl("cbChosen") as CheckBox; if (chosenGroup != null) { TextBox txtCustomLabel1 = e.Row.FindControl("txtCustomLabel1") as TextBox; TextBox txtCustomLabel2 = e.Row.FindControl("txtCustomLabel2") as TextBox; TextBox txtCustomLabel3 = e.Row.FindControl("txtCustomLabel3") as TextBox; TextBox txtCustomLabel4 = e.Row.FindControl("txtCustomLabel4") as TextBox; TextBox txtCustomLabel5 = e.Row.FindControl("txtCustomLabel5") as TextBox; TextBox txtValue1 = e.Row.FindControl("txtValue1") as TextBox; TextBox txtValue2 = e.Row.FindControl("txtValue2") as TextBox; TextBox txtValue3 = e.Row.FindControl("txtValue3") as TextBox; TextBox txtValue4 = e.Row.FindControl("txtValue4") as TextBox; TextBox txtValue5 = e.Row.FindControl("txtValue5") as TextBox; cb.Checked = true; txtCustomLabel1.Text = chosenGroup.CustomLabel1; txtCustomLabel2.Text = chosenGroup.CustomLabel2; txtCustomLabel3.Text = chosenGroup.CustomLabel3; txtCustomLabel4.Text = chosenGroup.CustomLabel4; txtCustomLabel5.Text = chosenGroup.CustomLabel5; txtValue1.Text = chosenGroup.Value1; txtValue2.Text = chosenGroup.Value2; txtValue3.Text = chosenGroup.Value3; txtValue4.Text = chosenGroup.Value4; txtValue5.Text = chosenGroup.Value5; } } }
private void SetChosenGroups(ProductGoogleCustomLabelGroupMappingOverviewModel group, bool chosen) { if (group != null) { if (chosen) { if (ExistInChosenGroups(group)) { ChosenCustomLabelGroups.RemoveAll(delegate(ProductGoogleCustomLabelGroupMappingOverviewModel arg) { return(arg.ProductId == group.ProductId); }); } ChosenCustomLabelGroups.Add(group); NotChosenCustomLabelGroups.RemoveAll(delegate(ProductGoogleCustomLabelGroupMappingOverviewModel arg) { return(arg.ProductId == group.ProductId); }); } else { ChosenCustomLabelGroups.RemoveAll(delegate(ProductGoogleCustomLabelGroupMappingOverviewModel arg) { return(arg.ProductId == group.ProductId); }); if (ExistInNotChosenGroups(group)) { NotChosenCustomLabelGroups.RemoveAll(delegate(ProductGoogleCustomLabelGroupMappingOverviewModel arg) { return(arg.ProductId == group.ProductId); }); } NotChosenCustomLabelGroups.Add(group); } } }