protected void btnSave_Click(object sender, EventArgs e) { int TotCount = 0; try { if (this.ValidateAndSave() == true) { foreach (GridViewRow gRow in grTotalSalary.Rows) { CheckBox chBox = new CheckBox(); chBox = (CheckBox)gRow.Cells[0].FindControl("chkBox"); if (chBox.Checked == true) { TextBox txtBox = new TextBox(); txtBox = (TextBox)gRow.Cells[3].FindControl("txtSeqNo"); if (txtBox.Text == "") { lblMsg.Text = "Please enter seq. no for the checked salary head."; return; } TotCount = TotCount + 1; } } objPayrollMgr.InsertTotalSalHead(grTotalSalary, TotCount); lblMsg.Text = "Payroll Salary Items has been set"; Common.EmptyTextBoxValues(this); //this.EntryMode(false); this.OpenRecord(); } } catch (Exception ex) { lblMsg.Text = ""; throw (ex); } }