protected void GvStd_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox tname = GvStd.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox; DataRow dr = ExamMst.GetDataByKey(Convert.ToInt32(GvStd.DataKeys[e.RowIndex].Value)); if (dr != null) { ExamMst std = new ExamMst(); std.ExamID = Convert.ToInt32(GvStd.DataKeys[e.RowIndex].Value); std.Name = txtstdname.Text; std.Total = txt_TotalMarks.Text != "" ? decimal.Parse(txt_TotalMarks.Text) : 100; std.UpdateDataByKey(); lbl.Text = "Record Updated Successfully"; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); } GvStd.EditIndex = -1; BindGridStd(); }
protected void btnaddstd_Click(object sender, EventArgs e) { ExamMst Standard = new ExamMst(); Standard.Name = txtstdname.Text; Standard.Total = txt_TotalMarks.Text != "" ? decimal.Parse(txt_TotalMarks.Text) : 100;; if (txtstdname.Text == "") { lbl.Text = "Exam name is required."; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); return; } if (ExamID != null) { Standard.ExamID = int.Parse(ExamID.ToString()); Standard.UpdateDataByKey(); lbl.Text = "Exam update Successfully."; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); BindGridStd(); txtstdname.Text = ""; ExamID = 0; } else { Standard.ExamID = ExamMst.GetNewExamID(); Standard.Insert(); lbl.Text = "Standered update Successfully."; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true); hidStdId = null; BindGridStd(); txtstdname.Text = ""; } btnaddstd.Text = "ADD"; }