protected void RadGrid_Attributes_RowDrop(object sender, GridDragDropEventArgs e) { if (e.DestDataItem != null && string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem.OwnerGridID == RadGrid_Attributes.ClientID) { ProductAttributeMgr myProductAttributeMgr = new ProductAttributeMgr(); List <AttributeIndex> myAttributeIndexs = myProductAttributeMgr.Get_Product_AttributeIndexes(_productid); AttributeIndex draggedAttributeIndex = Get_AttributeIndex_in_List(myAttributeIndexs, e.DraggedItems[0].GetDataKeyValue("Attribute_IndexID").ToString()); AttributeIndex destAttributeIndex = Get_AttributeIndex_in_List(myAttributeIndexs, e.DestDataItem.GetDataKeyValue("Attribute_IndexID").ToString()); int destIndex = myAttributeIndexs.IndexOf(destAttributeIndex); 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; } myAttributeIndexs.Remove(draggedAttributeIndex); myAttributeIndexs.Insert(destIndex, draggedAttributeIndex); foreach (AttributeIndex AttributeIndex in myAttributeIndexs) { // Product Variant e2Data[] UpdateData = { new e2Data("Attribute_IndexID", AttributeIndex.Attribute_IndexID), new e2Data("SortOrder", (myAttributeIndexs.IndexOf(Get_AttributeIndex_in_List(myAttributeIndexs, AttributeIndex.Attribute_IndexID)) + 1).ToString()) }; myProductAttributeMgr.Edit_Product_AttributeIndex(UpdateData); } RadGrid_Attributes.Rebind(); } }
protected void RadGrid_Attributes_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { ProductAttributeMgr myProductAttributeMgr = new ProductAttributeMgr(); RadGrid_Attributes.DataSource = myProductAttributeMgr.Get_Product_AttributeIndexes(_productid, true); }