void grdMetaLinks_RowCommand(object sender, GridViewCommandEventArgs e) { if (productGuid == Guid.Empty) { return; } if (store == null) { return; } Product product = new Product(productGuid); if (product.StoreGuid != store.Guid) { return; } GridView grid = (GridView)sender; string sGuid = e.CommandArgument.ToString(); if (sGuid.Length != 36) { return; } Guid guid = new Guid(sGuid); ContentMetaLink meta = metaRepository.FetchLink(guid); if (meta == null) { return; } switch (e.CommandName) { case "MoveUp": meta.SortRank -= 3; break; case "MoveDown": meta.SortRank += 3; break; } metaRepository.Save(meta); List <ContentMetaLink> metaList = metaRepository.FetchLinksByContent(product.Guid); metaRepository.ResortMeta(metaList); product.CompiledMeta = metaRepository.GetMetaString(product.Guid); product.Save(); BindMetaLinks(); updMetaLinks.Update(); }
void grdMetaLinks_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (productGuid == Guid.Empty) { return; } if (store == null) { return; } Product product = new Product(productGuid); if (product.StoreGuid != store.Guid) { return; } GridView grid = (GridView)sender; Guid guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString()); TextBox txtRel = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtRel"); TextBox txtHref = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtHref"); TextBox txtHrefLang = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtHrefLang"); ContentMetaLink meta = null; if (guid != Guid.Empty) { meta = metaRepository.FetchLink(guid); } else { meta = new ContentMetaLink(); if (siteUser != null) { meta.CreatedBy = siteUser.UserGuid; } meta.SortRank = metaRepository.GetNextLinkSortRank(product.Guid); meta.ModuleGuid = store.ModuleGuid; } if (meta != null) { meta.SiteGuid = siteSettings.SiteGuid; meta.ContentGuid = product.Guid; meta.Rel = txtRel.Text; meta.Href = txtHref.Text; meta.HrefLang = txtHrefLang.Text; if (siteUser != null) { meta.LastModBy = siteUser.UserGuid; } metaRepository.Save(meta); product.CompiledMeta = metaRepository.GetMetaString(product.Guid); product.Save(); } grid.EditIndex = -1; grdMetaLinks.Columns[2].Visible = true; BindMetaLinks(); updMetaLinks.Update(); }