private bool saveData() { bool blnResult = false; string strUpdatedBy = string.Empty; strUpdatedBy = Session["username"].ToString(); CheckBox chkSelect; Label lblmajor_code; var oBudget_money = new cBudget_money(); Budget_money_major budget_money_major = null; try { foreach (GridViewRow gvRow in GridView1.Rows) { chkSelect = (CheckBox)gvRow.FindControl("chkSelect"); if (chkSelect.Checked) { lblmajor_code = (Label)gvRow.FindControl("lblmajor_code"); budget_money_major = new Budget_money_major() { budget_money_detail_id = long.Parse(ViewState["budget_money_detail_id"].ToString()), major_code = lblmajor_code.Text, c_created_by = strUpdatedBy }; oBudget_money.SP_BUDGET_MONEY_MAJOR_INS(budget_money_major); } } blnResult = true; } catch (Exception ex) { lblError.Text = ex.Message; } finally { oBudget_money.Dispose(); } return(blnResult); }