try this right way of gridview bound
DataTable dt = null;
using (conn = new SqlConnection(ConfigurationManager.ConnectionStrings["tempdbConn"].ConnectionString))
{
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select row_number() OVER (ORDER BY id) AS sno,id,uname,totalMarks from tmp_table";
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
dt = new DataTable();
da.Fill(dt);
}
}
}
GridView1.DataSource = dt;
GridView1.DataBind();
Thanks