Aspose.Cells.GridWeb.Examples.CSharp.RowsAndColumns.GroupRows.btnLoad_Click C# (CSharp) Метод

btnLoad_Click() защищенный Метод

protected btnLoad_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат void
        protected void btnLoad_Click(object sender, EventArgs e)
        {
            GridWeb1.WorkSheets.Clear();

            // Connect database
            System.Data.OleDb.OleDbConnection oleDbConnection1 = new OleDbConnection();
            System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1 = new OleDbDataAdapter();
            System.Data.OleDb.OleDbCommand oleDbSelectCommand1 = new OleDbCommand();
            string path = (this.Master as Site).GetDataDir();
            oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\Worksheets\\Database\\Northwind.mdb";
            oleDbSelectCommand1.Connection = oleDbConnection1;
            oleDbDataAdapter1.SelectCommand = oleDbSelectCommand1;

            DataTable dataTable1 = new DataTable();
            dataTable1.Reset();

            try
            {
                oleDbSelectCommand1.CommandText = "SELECT * FROM Products";
                oleDbDataAdapter1.Fill(dataTable1);
                
                // Import data from database to grid web
                GridWeb1.WorkSheets.ImportDataView(dataTable1.DefaultView, null, null);
            }
            finally
            {
                // Close connection
                oleDbConnection1.Close();
            }
        }