asp.net web开发的一个问题

leiline 发布于 2015/09/21 15:01
阅读 67
收藏 0

写了一个web页面之间传值的小程序,要求用户输入学号之后打印出该学生的信息,然后有个归还按钮,将ordertime和reterntime内容清空。

在点击归还按钮之后,会报错

不清楚是不是session用的不对,第一次使用,还请指教,谢谢。

//获取学号,并跳转到showinformation
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using GROUP.Manage;

public partial class ReternC : System.Web.UI.Page
{
    BaseClass BaseClass1 = new BaseClass();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
      
        Session["user"] = TextBox1.Text;
        Server.Transfer("showinfor.aspx");
        Response.Write("<script>alert('alert.....');</script>");
        Response.Redirect("~/admin/showinfor.aspx");
    }

}


//打印学生信息,并将ordertime和reterntime设为null
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using GROUP.Manage;


public partial class showinfor : System.Web.UI.Page
{

    String user = "null";
    BaseClass BaseClass1 = new BaseClass();
    protected void Page_Load(object sender, EventArgs e)
    {

        user=Session["user"].ToString();
      
        String sql = "select * from users where studnum="+user;
        DataTable dt = new DataTable();//创建DataTable
        dt = BaseClass1.ReadTable(sql);//调用ReadTable方法获取查询结果

        if (dt.Rows.Count > 0)
        {
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        Session.Remove("user");
    }



    protected void Button1_Click(object sender, EventArgs e)
    {
       
        String sql = "update users set ordertime=null, reterntime=null where studnum="+user;
        BaseClass1.execsql(sql);
        Response.Write("<script>alert('alert.....');</script>");

    }
}



加载中
返回顶部
顶部