Save info in State View

   protected void Button1_Click(object sender, EventArgs e)
    {
        //Store Student Class in View State
        student _objStudent = new student();       
        _objStudent.AddStudent(int.Parse(TextBox1.Text.ToString()), TextBox2.Text.ToString());
        ViewState["StudentObject"] = _objStudent;
        TextBox1.Text = "";
        TextBox2.Text = "";
    }


    protected void Button2_Click(object sender, EventArgs e)
    {
        student _objStudent;
        _objStudent = (student)ViewState["StudentObject"];
     
        TextBox1.Text = _objStudent.Roll.ToString();
        TextBox2.Text = _objStudent.Name.ToString();
    }

posted @ 2010-02-17 22:03  greencolor  阅读(131)  评论(0编辑  收藏  举报