protected void btnUpdate_Click(object sender, EventArgs e) { DocumentDetails docObj = new DocumentDetails(); ELibraryDocumentBL docBLObj = new ELibraryDocumentBL(); try { InitializeCombo(); if (cbnDocumentID.SelectedIndex == -1) { throw new ELibraryException("Select Document ID"); } if (cboDocumentType.SelectedIndex == -1) { throw new ELibraryException("Select Discipline"); } if (cboDiscipline.SelectedIndex == -1) { throw new ELibraryException("Select Document Type"); } docObj.DocumentID = Convert.ToInt32(cbnDocumentID.SelectedValue); //Session["DocumentId"] = cbnDocumentID.SelectedValue; string folderPath = Server.MapPath("~/Files/"); if (!Directory.Exists(folderPath)) { //If Directory (Folder) does not exists. Create it. Directory.CreateDirectory(folderPath); } string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName); if (fileName == "") { throw new ELibraryException("Select File"); } FileUpload1.SaveAs(folderPath + Path.GetFileName(FileUpload1.FileName)); docObj.DocumentPath = folderPath + Path.GetFileName(FileUpload1.FileName); docObj.DocumentName = txtDocumentName.Text; docObj.DocumentDescription = txtDescription.Text; docObj.DocumentTypeID = docBLObj.GetDocumentTypeIDBL(cboDocumentType.SelectedItem.ToString()); docObj.DisciplineID = docBLObj.GetDisciplineIDBL(cboDiscipline.SelectedItem.ToString()); docObj.Title = txtTitle.Text; docObj.Author = txtAuthor.Text; double price; bool isValidPrice = double.TryParse(txtPrice.Text, out price); if (!isValidPrice) { throw new ELibraryException("Invalid price"); } docObj.Price = price; docObj.UploadDate = DateTime.Today; if (docBLObj.UpdateDocumentBL(docObj)) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Updated')", true); //string str = "<script>alert(\"Updated Successfully\");</script>"; } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Updation Failed')", true); } } catch (ELibraryException ex) { ErrorLogging erLog = new ErrorLogging(); erLog.LogError(ex.Message); ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message + "')", true); } }