protected void SourceGrid_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
        {
            rowValues = new List <object>();
            switch (e.Parameters)
            {
            case "removeSelectedRows":
                rowValues = TargetGrid.GetSelectedFieldValues(fieldNames);
                var categoryIDs = new StringBuilder();

                for (int i = 0; i < rowValues.Count(); i++)
                {
                    var categoryID = (rowValues[i] as object[])[0];
                    if (i < rowValues.Count() - 1)
                    {
                        categoryIDs.AppendFormat("{0}, ", categoryID);
                    }
                    else
                    {
                        categoryIDs.Append(categoryID);
                    }
                }

                if (categoryIDs.Length > 0)
                {
                    TargetDS.DeleteCommand = string.Format("DELETE FROM [CategoriesUpdated] WHERE [CategoryID] IN ({0})", categoryIDs);
                    TargetDS.Delete();

                    foreach (object[] rowValue in rowValues)
                    {
                        SourceDS.InsertCommand = string.Format(
                            "INSERT INTO [Categories] ([CategoryID], [CategoryName], [Description]) VALUES ({0}, '{1}', '{2}')",
                            rowValue[0], rowValue[1], rowValue[2]);
                        SourceDS.Insert();
                    }
                    SourceGrid.DataBind();
                }
                break;

            case "removeAllRows":
                for (int i = 0; i < TargetGrid.VisibleRowCount; i++)
                {
                    rowValues.Add(TargetGrid.GetRowValues(i, fieldNames));
                }
                if (rowValues.Count > 0)
                {
                    TargetDS.DeleteCommand = "DELETE * FROM [CategoriesUpdated]";
                    TargetDS.Delete();

                    foreach (object[] rowValue in rowValues)
                    {
                        SourceDS.InsertCommand = string.Format(
                            "INSERT INTO [Categories] ([CategoryID], [CategoryName], [Description]) VALUES ({0}, '{1}', '{2}')",
                            rowValue[0], rowValue[1], rowValue[2]);
                        SourceDS.Insert();
                    }
                    SourceGrid.DataBind();
                }
                break;
            }
        }