public void load_page(decimal page) { using (var connection = DBConnection.getInstance().getConnection()) { SqlCommand query = new SqlCommand(this.query, connection); query.CommandType = CommandType.StoredProcedure; query.Parameters.Add(new SqlParameter("@pagina", page)); query.Parameters.Add(new SqlParameter("@cantidad_resultados_por_pagina", this.page_size)); this.query_params.ForEach((pair) => query.Parameters.Add(new SqlParameter(pair.Key, pair.Value))); //Creo el adapter usando el select_query SqlDataAdapter adapter = new SqlDataAdapter(query); //Lleno el dataset y lo seteo como source del dataGridView DataTable table = new DataTable(); adapter.Fill(table); this.data_grid.DataSource = table; this.data_grid.ReadOnly = true; this.data_grid.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.data_grid.MultiSelect = false; this.data_grid.AllowUserToAddRows = false; // Para que oculte la columna del COUNT this.data_grid.Columns[0].Visible = false; int total_pages = 0; if (this.data_grid.Rows.Count > 0) { total_pages = (int)this.data_grid.Rows[0].Cells[0].Value; } this.page_count_label.Text = "/ " + (total_pages / this.page_size).ToString(); this.current_page.Maximum = total_pages; } this.prev.Enabled = !(this.current_page.Value == this.current_page.Minimum); this.next.Enabled = !(this.current_page.Value == this.current_page.Maximum); }