protected void Page_Load(object sender, EventArgs e) { String sub, tchr, f; int m, y; sub = Convert.ToString(Session["subject"]); tchr = Convert.ToString(Session["teacher"]); m = Convert.ToInt32(Session["month"]); y = Convert.ToInt32(Session["year"]); f = Convert.ToString(Session["code"]); Label1.Text = Convert.ToString(m); Label2.Text = Convert.ToString(y); Label8.Text = Convert.ToString(f); Label3.Text = sub; Label4.Text = tchr; if (!IsPostBack) { dbconnect db1 = new dbconnect(); dbconnect db2 = new dbconnect(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select * from tbl_qstn where qno=" + i + ""; SqlCommand cmd1 = new SqlCommand(); cmd1.CommandText = "select count(*) from tbl_qstn"; count = db2.id(cmd1); SqlDataReader dr = db1.executeread(cmd); while (dr.Read()) { Label5.Text = dr[0].ToString(); TextBox1.Text = dr[1].ToString(); } } }