protected void DeleteStudent_Click(object sender, EventArgs e)
 {
     if (TextBoxDeleteId.Text.Equals("") )
     {
         Response.Write("<script language='javascript'>alert('Please fill the Delete Id field.');</script>");
     }
     else
     {
         String stu_Id = TextBoxDeleteId.Text;
         StudentsDBDataClassesDataContext db = new StudentsDBDataClassesDataContext();
         Student stu = db.Students.Single(u => u.Student_Id == stu_Id);
         db.Students.DeleteOnSubmit(stu);
         db.SubmitChanges();
         TextBoxDeleteId.Text = "";
         GridView1.DataBind();
     }
 }
Beispiel #2
0
 protected void DeleteStudent_Click(object sender, EventArgs e)
 {
     if (TextBoxDeleteId.Text.Equals(""))
     {
         Response.Write("<script language='javascript'>alert('Please fill the Delete Id field.');</script>");
     }
     else
     {
         String stu_Id = TextBoxDeleteId.Text;
         StudentsDBDataClassesDataContext db = new StudentsDBDataClassesDataContext();
         Student stu = db.Students.Single(u => u.Student_Id == stu_Id);
         db.Students.DeleteOnSubmit(stu);
         db.SubmitChanges();
         TextBoxDeleteId.Text = "";
         GridView1.DataBind();
     }
 }
Beispiel #3
0
 protected void ButtonAddStudent_Click(object sender, EventArgs e)
 {
     if (TextBoxID.Text.Equals("") || TextBoxName.Text.Equals("") || TextBoxAge.Text.Equals("") || TextBoxUniversity.Text.Equals(""))
     {
         Response.Write("<script language='javascript'>alert('Please fill all the fields.');</script>");
     }
     else
     {
         Student stu = new Student();
         stu.Student_Age        = Convert.ToInt32(TextBoxAge.Text);
         stu.Student_Name       = TextBoxName.Text;
         stu.Student_Id         = TextBoxID.Text;
         stu.Student_University = TextBoxUniversity.Text;
         StudentsDBDataClassesDataContext db = new StudentsDBDataClassesDataContext();
         db.Students.InsertOnSubmit(stu);
         db.SubmitChanges();
         TextBoxID.Text         = "";
         TextBoxAge.Text        = "";
         TextBoxName.Text       = "";
         TextBoxUniversity.Text = "";
     }
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (TextBoxID.Text.Equals("") || TextBoxName.Text.Equals("") || TextBoxAge.Text.Equals("") || TextBoxUniversity.Text.Equals(""))
     {
         Response.Write("<script language='javascript'>alert('Please fill all the fields.');</script>");
     }
     else
     {
         String stu_Id = TextBoxID.Text;
         StudentsDBDataClassesDataContext db = new StudentsDBDataClassesDataContext();
         Student stu = db.Students.Single(u => u.Student_Id == stu_Id);
         stu.Student_Age = Convert.ToInt32(TextBoxAge.Text);
         stu.Student_Name = TextBoxName.Text;
         stu.Student_University = TextBoxUniversity.Text;
         db.SubmitChanges();
         TextBoxID.Text = "";
         TextBoxAge.Text = "";
         TextBoxName.Text = "";
         TextBoxUniversity.Text = "";
         GridView1.DataBind();
     }
 }