C# Datagridview Database Operations: Next: Delete Row From Datagridview by Right Click
C# Datagridview Database Operations: Next: Delete Row From Datagridview by Right Click
C# Datagridview Database Operations: Next: Delete Row From Datagridview by Right Click
The DataGridView can display data in Bound mode, unbound mode and Virtual
mode . Bound mode is suitable for managing data using automatic interaction
with the data store. One very common use of the DataGridView control is binding
to a table in a database. Unbound mode is suitable for displaying relatively small
amounts of data that you manage programmatically. Virtual mode gives you a
higher degree of control by allowing you to wait until a cell is actually being
displayed to provide the value it will contain.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
SqlCommand sCommand;
SqlDataAdapter sAdapter;
SqlCommandBuilder sBuilder;
DataSet sDs;
DataTable sTable;
public Form1()
{
InitializeComponent();
}
http://csharp.net-informations.com/datagridview/csharp-datagridview-tutorial.htm
private void button1_click(...)
{
using (SqlConnection cnn = new SqlConnection("connection string")) {
GridView1.DataSource = dt;
GridView1.DataBind();
}
using System.Data;
using System.Data.SqlClient;
Opcion1:
da.Fill(dt);
dataGridView1.DataSource = dt;
cn.Close();
}
Opcion 2:
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
cn.Close();
Existe muchos metodos al momento de querer cargar una datagridview aqui tienen un metodo simple y eficaz que lo carga directamente
desde una tabla.