protected void RadGrid_VariantSpliter_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { ProductVariantMgr myProductVariantMgr = new ProductVariantMgr(); RadGrid_VariantSpliter.DataSource = myProductVariantMgr.Get_Product_Variant_Spliters(Request["Product_VariantID"]); //RadGrid_VariantSpliter.DataBind(); }
protected void RadGrid_VariantSpliter_RowDrop(object sender, GridDragDropEventArgs e) { if (string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem.OwnerGridID == RadGrid_VariantSpliter.ClientID) { if (e.DraggedItems[0].OwnerGridID == RadGrid_VariantSpliter.ClientID) { #region items are Spliter if (e.DestDataItem != null) { ProductVariantMgr myProductVariantMgr = new ProductVariantMgr(); Variant_Spliter myVariant_Spliter = myProductVariantMgr.Get_Product_Variant_Spliter(e.DestDataItem.GetDataKeyValue("Variant_SpliterID").ToString()); List <Variant_Spliter> myVariant_Spliters = myProductVariantMgr.Get_Product_Variant_Spliters(myVariant_Spliter.Product_VariantID, "SortOrder"); Variant_Spliter draggedVariant_Spliter = Get_Variant_Spliter_in_List(myVariant_Spliters, e.DraggedItems[0].GetDataKeyValue("Variant_SpliterID").ToString()); Variant_Spliter destVariant_Spliter = Get_Variant_Spliter_in_List(myVariant_Spliters, e.DestDataItem.GetDataKeyValue("Variant_SpliterID").ToString()); int destIndex = myVariant_Spliters.IndexOf(destVariant_Spliter); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destIndex += 1; } myVariant_Spliters.Remove(draggedVariant_Spliter); myVariant_Spliters.Insert(destIndex, draggedVariant_Spliter); foreach (Variant_Spliter Variant_Spliter in myVariant_Spliters) { // Product Variant e2Data[] UpdateData = { new e2Data("Variant_SpliterID", Variant_Spliter.Variant_SpliterID), new e2Data("SortOrder", (myVariant_Spliters.IndexOf(Get_Variant_Spliter_in_List(myVariant_Spliters, Variant_Spliter.Variant_SpliterID)) + 1).ToString()) }; myProductVariantMgr.Edit_Product_Variant_Spliter(UpdateData); } } #endregion Control_Init(); } } }