private bool saveDataDetail() { bool blnResult = false; string strScript = string.Empty; cBudget_money oBudget_money = new cBudget_money(); HiddenField hddbudget_money_major_id = null; AwNumeric txtbudget_money_major_plan = null; AwNumeric txtbudget_money_major_plan2 = null; AwNumeric txtbudget_money_major_plan3 = null; Budget_money_major budget_money_major = null; try { #region set Data //GridViewRow item = (GridViewRow)GridView1.Controls[0].Controls[0]; for (var index = 0; index < GridViewMajor.Rows.Count; index++) { hddbudget_money_major_id = (HiddenField)GridViewMajor.Rows[index].FindControl("hddbudget_money_major_id"); txtbudget_money_major_plan = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan"); txtbudget_money_major_plan2 = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan2"); txtbudget_money_major_plan3 = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan3"); budget_money_major = new Budget_money_major { budget_money_major_id = long.Parse(hddbudget_money_major_id.Value), budget_money_major_plan = decimal.Parse(txtbudget_money_major_plan.Value.ToString()), budget_money_major_plan2 = decimal.Parse(txtbudget_money_major_plan2.Value.ToString()), budget_money_major_plan3 = decimal.Parse(txtbudget_money_major_plan3.Value.ToString()), c_updated_by = Session["username"].ToString() }; oBudget_money.SP_BUDGET_MONEY_MAJOR_UPD(budget_money_major); } blnResult = true; } catch (Exception ex) { if (ex.Message.Contains("duplicate key")) { MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ"); } else { lblError.Text = ex.Message.ToString(); } } finally { oBudget_money.Dispose(); } return(blnResult); }