You can achieve this with single call of database. Review below block of code. I make two small change and this will give proper result with less time.
string strIds = string.Empty;
for (int i = 0; i < 45; i++)
{
strIds = strIds == string.Empty ? "'" + i.ToString() + "'" : (",'" + i.ToString() + "'");
}
string str = " SELECT * from Table1 where id IN (" + strIds + ")";
SqlCommandcmd = new SqlCommand(str, conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adp.Fill(dt);
gridview1.DataSource = dt;
gridview1.DataBind();