datagridview RRS feed

  • Question

  • how is the datagrid view works ' how can i concet the data grid view to the database or to a file
    Friday, June 20, 2014 7:18 AM


  • Hi Kobbi,

    Do you mean DataGridView in winform? If so, msdn  provide a standard introduction and sample for Datagridview.

    More details, Please click here.

    We can use DataSource property  to gets or sets the data source that the DataGridView is displaying data for.

      private void Export_Click(object sender, EventArgs e)
                string conString = @"Data Source=(localdb)\Projects;Initial Catalog=TestDB;Integrated Security=True";
                SqlConnection sqlCon = new SqlConnection(conString);
                SqlDataAdapter da = new SqlDataAdapter("select * from USERS_INFORMATION", sqlCon);
                DataTable dtMainSQLData = new DataTable();
                dataGridView1.DataSource = dtMainSQLData;
    Have a nice day!

    • Marked as answer by Fred Bao Monday, June 30, 2014 6:07 AM
    Friday, June 20, 2014 10:18 AM