none
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

Answers

  • 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);
                sqlCon.Open();
    
                SqlDataAdapter da = new SqlDataAdapter("select * from USERS_INFORMATION", sqlCon);
    
                DataTable dtMainSQLData = new DataTable();
    
                da.Fill(dtMainSQLData);
                dataGridView1.DataSource = dtMainSQLData;
    }
    Have a nice day!

    Friday, June 20, 2014 10:18 AM