Aspose.Cells.GridWeb.Examples.CSharp.Articles.BindDataUsingWorksheetDesigner.GridWeb1_CustomCommand C# (CSharp) Method

GridWeb1_CustomCommand() protected method

protected GridWeb1_CustomCommand ( object sender, string command ) : void
sender object
command string
return void
        protected void GridWeb1_CustomCommand(object sender, string command)
        {
            switch (command)
            {
                case "UPDATE":
                    // Only available for local users.
                    if (Request.UserHostAddress == "127.0.0.1")
                    {
                        // Create path to database file
                        ExampleDatabase db = new ExampleDatabase();
                        string path = (this.Master as Site).GetDataDir();

                        // Create connection string
                        db.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\Miscellaneous\\Database\\demos.mdb";
                        try
                        {
                            // Update database
                            db.oleDbDataAdapter1.Update((DataSet)GridWeb1.WebWorksheets[0].DataSource);
                        }
                        finally
                        {
                            // Close connection
                            db.oleDbConnection1.Close();
                        }
                    }
                    else
                    {
                        // Set error message
                        ShowErrorMsg("Can't update from remote machine!");
                    }
                    break;

                case "ADD":
                    if (GridWeb1.ActiveSheetIndex == 0)
                    {
                        // Create new active row
                        GridWeb1.WebWorksheets.ActiveSheet.CreateNewBindRow();

                        // Scrolls the panel to the bottom.
                        GridWeb1.ViewPanelScrollTop = "1200";
                    }
                    break;

                case "DELETE":
                    if (GridWeb1.ActiveSheetIndex == 0)
                    {
                        if (GridWeb1.ActiveCell != null)
                            // Delete bind row
                            GridWeb1.WebWorksheets.ActiveSheet.DeleteBindRow(GridWeb1.ActiveCell.Row);
                    }
                    break;
            }
        }