protected void RadGrid_Options_RowDrop(object sender, GridDragDropEventArgs e) { if (e.DestDataItem != null && string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem.OwnerGridID == RadGrid_Options.ClientID) { ProductAttributeMgr myProductAttributeMgr = new ProductAttributeMgr(); List <Product_Attribute> myProduct_Attributes = myProductAttributeMgr.Get_Product_Attributes(_attribute_indexid); Product_Attribute draggedAttribute = Get_Attribute_in_List(myProduct_Attributes, e.DraggedItems[0].GetDataKeyValue("AttributeID").ToString()); Product_Attribute destAttribute = Get_Attribute_in_List(myProduct_Attributes, e.DestDataItem.GetDataKeyValue("AttributeID").ToString()); int destIndex = myProduct_Attributes.IndexOf(destAttribute); 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; } myProduct_Attributes.Remove(draggedAttribute); myProduct_Attributes.Insert(destIndex, draggedAttribute); foreach (Product_Attribute myAttribute in myProduct_Attributes) { // Product Variant e2Data[] UpdateData = { new e2Data("AttributeID", myAttribute.AttributeID), new e2Data("SortOrder", (myProduct_Attributes.IndexOf(Get_Attribute_in_List(myProduct_Attributes, myAttribute.AttributeID)) + 1).ToString()) }; myProductAttributeMgr.Edit_Product_Attribute(UpdateData); } RadGrid_Options.Rebind(); } }
protected void RadGrid_Options_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { ProductAttributeMgr myProductAttributeMgr = new ProductAttributeMgr(); RadGrid_Options.DataSource = myProductAttributeMgr.Get_Product_Attributes(_attribute_indexid); }