DataGridView Implementation with DataSet
SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["studentConnectionString"].ConnectionString);
string sql = "SELECT * FROM student";
SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);
DataSet ds = new DataSet();
connection.Open();
dataadapter.Fill(ds, "student");
connection.Close();
dataGridView1.DataSource = ds;
// dataGridView1.DataMember = "student"; //DataMember -- if the DataSet content More than one table then binding the particular table with grid we use this
dataGridView1.DataBind();
string sql = "SELECT * FROM student";
SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);
DataSet ds = new DataSet();
connection.Open();
dataadapter.Fill(ds, "student");
connection.Close();
dataGridView1.DataSource = ds;
// dataGridView1.DataMember = "student"; //DataMember -- if the DataSet content More than one table then binding the particular table with grid we use this
dataGridView1.DataBind();