See below code,
1. Read the records from the database to a datareader
2. then assign the datareader results to the gridview
In this example I am using Mysql to demonstrate. If you are using SQL Server. there is no much different except the you need to use respective classes.
private void GetResults()
{
MySqlConnection conn = new MySqlConnection("Database=potentiality_live;Data Source=eu;User Id=ptly;Password=phat40");
string query;
MySqlCommand SqlCommand;
MySqlDataReader reader;
MySqlDataAdapter adapter = new MySqlDataAdapter();
conn.Open();
query = "SELECT id,date_time,link FROM'sdfsdfsdf'";
SqlCommand = new MySqlCommand(query, conn);
adapter.SelectCommand = new MySqlCommand(query, conn);
reader = SqlCommand.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
}
Feel free to ask me if you have any further issues. If this solution is working then please click on the accept solution.
thank you