本文介绍了如何使用session将值传递给textbox并重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试过但它不起作用。 结果屏幕如下; Label1你得分80%的分数 Label2抱歉你失败了你必须再次参加复赛。 登录界面如下; studentid textbox1 studentname textbox2 i我在结果画面页面写代码。 in结果屏幕页面我有一个名为Reexam的按钮 在该重新检查按钮中,如果学生失败,我想写代码, 然后studentntid和studentname将显示在登录屏幕的textbox1和textbox2的登录屏幕上。 在Reexam按钮代码中如下; (我在结果屏幕页面写代码) sql =select s.StudId,s.StudName,s.Marks ,来自studdet s的b.class,批次b,其中Marks< 59和s.bthid = b.bthid和StudId =''+ Session [StudID] +''; 尝试 { Dr = SCon.ReadSql(sql); Dr.Read(); if (Dr.HasRows == true) { string strstudid = Dr [0] .ToString(); string strstudname = Dr [ 1] .ToString(); Session [StudID] = strstudid; Session [StudName] = strstudname; 博士.Close(); Response.Redirect(login.aspx); } } catch(exception ex2) { this.Label4.Text = ex2.Message。 ToString(); 返回; } 但是当我在登录屏幕上运行学生ID和学生姓名不会显示在文本框中。 请帮帮我。 i试过但不是工作? 注意:我想在结果屏幕页面写代码。 问候, Narasiman P.i tried but it is not working. Result Screen as follows; Label1 you are scored 80% of marks Label2 sorry you are failed you have to attend the reexam again. Login screen as follows; studentid textbox1 studentname textbox2 i am writing the code in Result Screen page. in the Result Screen page i have one button called Reexam in that reexam button i want to write the code if the student failed, then that studentid and studentname, will be displayed into the Login screen of textbox1 and textbox2 in the Login screen.In the Reexam button code as follows; ( i write the code in the Result Screen page) sql = "select s.StudId,s.StudName,s.Marks,b.class from studdet s, batch b where Marks < 59 and s.bthid = b.bthid and StudId = ''" + Session["StudID"] + "''"; try { Dr = SCon.ReadSql(sql); Dr.Read(); if (Dr.HasRows == true) { string strstudid = Dr[0].ToString(); string strstudname = Dr[1].ToString(); Session["StudID"] = strstudid; Session["StudName"] = strstudname; Dr.Close(); Response.Redirect("login.aspx"); } } catch (Exception ex2) { this.Label4.Text = ex2.Message.ToString(); return; }but when i run in the login screen student id and student name will not displayed in the textbox.please help me.i tried but it is not working?Note : i want to write the code in the Result Screen page.Regards,Narasiman P.推荐答案如果你想在Label1或Label2中显示StudID。 使用此 Label1.text = Session [StudID]。ToString(); Label2.text = Session [StudID]。ToString();If you want to show StudID in Label1 or Label2.use thisLabel1.text=Session["StudID"].ToString();Label2.text=Session["StudID"].ToString(); 这篇关于如何使用session将值传递给textbox并重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-03 15:43