Exemple #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BBSDataContext lq   = new BBSDataContext();
            BBSNote        note = new BBSNote();

            note.bnSubject = txtbnSubject.Text;
            note.bnContent = txtbnContent.Text;
            note.bnID      = Convert.ToInt16(Session["uID"].ToString());
            note.bnAddTime = System.DateTime.Now;
            lq.BBSNote.InsertOnSubmit(note);
            lq.SubmitChanges();
            Response.Redirect("BBSNoteList.aspx");
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            BBSDataContext lq   = new BBSDataContext(); //实例化LINQ类
            BBSNote        note = new BBSNote();        //创建一个新对象

            note.bnSubject = txtbnSubject.Text;
            note.bnContent = txtbnContent.Text;
            note.uID       = Convert.ToInt32(Session["uID"]);
            note.bnAddTime = System.DateTime.Now;
            lq.BBSNote.InsertOnSubmit(note);                           //执行插入数据操作
            lq.SubmitChanges();                                        //提交数据库
            Response.Redirect("BBSNoteList.aspx?id=" + Request["id"]); //重新定位到该页面
        }