This means that query is executing successfully in database but not returning any rows. Your session value might be giving Empty String. Put a breakpoint and check for the session value. Try Like this:
if(Session["idq"]!= "")
{
con.Open();
MySqlCommand md = new MySqlCommand("select answer,userid,date from thread where forumid='"+Session["idq"].ToString()+"' ", con);
MySqlDataAdapter ada = new MySqlDataAdapter(md);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
ada.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
else
{
}
Before using the session value you should always check for its existence. Check whether
Session["idq"]
is null or not before using it.
--Amit