protected void btnSave_Click(object sender, EventArgs e) { foreach (Telerik.Web.UI.GridDataItem item in grdResult.MasterTableView.Items) { HiddenField hdnExamPaperId = item.FindControl("hdnExamPaperId") as HiddenField; HiddenField hdnExamPlaceId = item.FindControl("hdnExamPlaceId") as HiddenField; HiddenField hdnExamDate = item.FindControl("hdnExamDate") as HiddenField; HiddenField hdnExamTime = item.FindControl("hdnExamTime") as HiddenField; TextBox txtTrackNumber = item.FindControl("txtTrackNumber") as TextBox; Label lblExamPlaceName = item.FindControl("lblExamPlaceName") as Label; if (hdnExamPaperId != null && txtTrackNumber != null && lblExamPlaceName != null && hdnExamPlaceId != null && hdnExamDate != null && hdnExamTime != null) { var examPaper = !string.IsNullOrEmpty(hdnExamPaperId.Value) ? Convert.ToInt32(hdnExamPaperId.Value) : 0; if (eBusiness.AddOrUpdateExamPaper(examPaper, txtTrackNumber.Text, Convert.ToInt32(hdnExamPlaceId.Value) , hdnExamDate.Value, hdnExamTime.Value)) { cBusiness.InsertIntoUserLog(int.Parse(Session[sessionNames.userID_Karbar].ToString()), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_Karbar].ToString()), 169, "ثبت کد مرسوله شهر " + lblExamPlaceName.Text, examPaper); lblSuccessMessage.Text = "تغییرات با موفقیت ذخیره شد."; } } } pnlSuccessMessageBox.Visible = true; }