Bind your table's data into your DataGridView


 

private void BindData(DataGrid DataGrid1, String TableName)
{

          //Make The New Connection

          SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["<<YourConnectionString>>"]);
          SqlCommand cmd=new SqlCommand();

          //Pass The Query

          cmd.CommandText="SELECT * FROM Students";
          cmd.Connection=conn;

          //Open The Connection

          cmd.Connection.Open();
          SqlDataReader dr=cmd.ExecuteReader();

          //Give DataSource As Object Of SqlDataReader

          DataGridView1.DataSource=dr;

          //Bind The Read Data To Your DataGridView

          DataGridView1.DataBind();

          //Finally Close The Connection

          cmd.Connection.Close();
}


Next Recommended Reading Export DataGridView Data To PDF In C#