} //end OnPreRender #endregion #region Button Event Handlers protected void savestudent_Click(object sender, EventArgs e) { //Perform validations Page.Validate(); if (!Page.IsValid) { this.m_errorList.Add(BaseBusiness.ERR_MSG_VALIDATION_FAILED); return; } if (filestudent != null) { if (filestudent.PostedFile.ContentLength != 0) { try { string strLineData; string[] arrImportData; string strDelim = ","; char[] arrDelim = strDelim.ToCharArray(); StreamReader objSR; Stream objStream; objStream = filestudent.FileContent; objSR = new StreamReader(objStream); objSR.BaseStream.Seek(0, SeekOrigin.Begin); objSR.BaseStream.Position = 0; //read process line-by-line; loop until all lines have been read & imported. //Enable transaction support m_objDA.TransactionEnable(); m_objDA.TransactionBegin(); int idx = 0; while (objSR.Peek() >= 0) { strLineData = objSR.ReadLine(); arrImportData = strLineData.Split(arrDelim); // skip first line if (idx == 0) { strLineData = objSR.ReadLine(); arrImportData = strLineData.Split(arrDelim); idx += 1; } m_objDA.UpdateStudentData(arrImportData[0], arrImportData[1]); } m_objDA.TransactionCommit(); //save file //display successful msg this.lblUserMessage.Text = "Student List Updated"; } //end try catch (Exception ex) { m_objDA.TransactionRollback(); string strError = string.Format("Exception occurred in MainControl.savestudent_Click ... {0}", ex.Message); this.m_errorList.Add(strError); Utilities.CriticalErrorNotification(base.AnyErrorsNoHTML(this.m_errorList), base.m_bSendErrorEmails); } finally { } } } } //savestudent_Click