我想知道在后台管理中怎么使用session?

解决方案 »

  1.   

    Session["user_name_gly"]=TextBox1.Text;if(Session["user_name_gly"]==null)
    {
    Response.Redirect("admin_login.aspx");
    }
      

  2.   

    Session["变量名"]=TextBox1.text;string aaa=Session["变量名"];这样就OK啦!
      

  3.   

    Session["变量名"]=?
    string s = Session["变量名"]
      

  4.   

    Session["变量名"]=?取出 值  =Session["变量名"]
      

  5.   

    例如如果你想在新的请求页面时显示上一个下拉框的值,可以这样。
     protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownListMonitor.SelectedValue = (String)Session["monitor"];
                Session.Remove("monitor");
            }
        }
    protected void btnOK_Click(object sender, EventArgs e)
        {
           string path = DropDownList1.SelectedValue;
           Session("monitor") = monitor;
        }
      

  6.   

    Session["temp"] = XXX ;//给Session赋值 object temp=XXX  object yyy = (object)Session["temp"];//取出Session所存类型为temp的对象object可以换成string,int,DataView,ReportDocument等类型