protected void BtnAddoop_Click(object sender, EventArgs e) { try { if (RadioPresentoop.Checked) { S_Attendance = "Present"; } else if (RadioAbsentoop.Checked) { S_Attendance = "Absent"; } var query = "Insert into OOP_Table values('" + TxtRegnooop.Text + "','" + TxtSnameoop.Text + "','" + S_Attendance + "')"; using (var conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='|DataDirectory|\Classes.mdf';Integrated Security=True")) { var comm = new SqlCommand(query, conn); conn.Open(); comm.ExecuteNonQuery(); conn.Close(); LblMessageOOP.Text = "Student added successfully"; TxtSnameoop.Text = TxtRegnooop.Text = S_Attendance = ""; GvOOP.DataBind(); } } catch (Exception ex) { LblMessageOOP.Text = ex.Message; } RefreshPage(); }
private void RefreshPage() { BtnEditoop.Visible = false; BtnAddoop.Visible = true; BtnDeleteoop.Visible = false; TxtSnameoop.Text = TxtRegnooop.Text = S_Attendance = ""; GvOOP.DataBind(); ListOOP.DataBind(); }