protected void Button1_Click(object sender, EventArgs e) { using (studentDataContext studentDataContext1 = new studentDataContext()) { try { student1 student = studentDataContext1.student1s.SingleOrDefault (x => x.sid == int.Parse(sid.Text.ToString())); if (student == null) { Label1.Text = "pleas enter valid input"; Label1.ForeColor = System.Drawing.Color.Red; } else { name.Text = student.name; cpi.Text = student.cpi; sem.Text = student.sem; contacno.Text = student.contactno; emailid.Text = student.emailid; } } catch (System.NullReferenceException err) { Label1.Text = "pleas enter valid input"; Label1.ForeColor = System.Drawing.Color.Red; } } }
protected void Button2_Click(object sender, EventArgs e) { using (studentDataContext studentDataContext1 = new studentDataContext()) { student1 student = studentDataContext1.student1s.SingleOrDefault (x => x.sid == int.Parse(sid.Text.ToString())); student.name = name.Text; student.cpi = cpi.Text; student.sem = sem.Text; student.contactno = contacno.Text; student.emailid = emailid.Text; studentDataContext1.SubmitChanges(); } }
protected void TextBox1_TextChanged(object sender, EventArgs e) { using (studentDataContext studentDataContext = new studentDataContext()) { int id_del = int.Parse(sid.Text.ToString()); student1 stu = studentDataContext.student1s.SingleOrDefault(x => x.sid == id_del); if (stu == null) { Label1.Text = "pleas enter valid input"; Label1.ForeColor = System.Drawing.Color.Red; } else { Label1.Text = ""; studentDataContext.student1s.DeleteOnSubmit(stu); studentDataContext.SubmitChanges(); } } }
protected void Button1_Click(object sender, EventArgs e) { using (studentDataContext studentDataContext = new studentDataContext()) { String cpi_in = cpi.Text; String name_in = name.Text; String sem_in = sem.Text; String contacno_in = contacno.Text; String emailid_in = emailid.Text; student1 student = new student1 { cpi = cpi_in, name = name_in, contactno = contacno_in, emailid = emailid_in, sem = sem_in, }; studentDataContext.student1s.InsertOnSubmit(student); studentDataContext.SubmitChanges(); } }
partial void Deletestudent1(student1 instance);
partial void Updatestudent1(student1 instance);
partial void Insertstudent1(student1 instance);