protected void Button1_Click(object sender, EventArgs e) { if(TextBox1.Text!=""&&TextBox2.Text!="") { var student = new Student { Number=TextBox1.Text, Name=TextBox2.Text, Sex=DropDownList3.Text, Age=TextBox3.Text, Class=DropDownList1.Text+DropDownList2.Text, Contact=TextBox4.Text, Adress=TextBox5.Text }; data.Student.InsertOnSubmit(student); data.SubmitChanges(); Response.Write("<script language='javascript'>alert('录入成功!')</script>"); } else { Response.Write("<script language='javascript'>alert('数据不合法,请重新输入!');history.back();</script>"); } }
partial void UpdateStudent(Student instance);
partial void DeleteStudent(Student instance);
partial void InsertStudent(Student instance);