protected void gvComments_RowCommand(object sender, GridViewCommandEventArgs e) { int commentID = Convert.ToInt32(e.CommandArgument); CarrierComment comment = null; if (e.CommandName == "DoEdit") { ViewState["CarrierCommentID"] = e.CommandArgument.ToString(); comment = CarrierCommentManager.Get(commentID); if (comment != null) { showEditPanel(); txtComment.Text = comment.CommentText; } } else if (e.CommandName == "DoDelete") { CarrierCommentManager.Delete(commentID); showGridPanel(); bindComments(); } }
protected void btnSave_Click(object sender, EventArgs e) { int commentID = 0; Page.Validate("Comment"); if (!Page.IsValid) { return; } CarrierComment comment = null; // carrier being edited commentID = Convert.ToInt32(ViewState["CarrierCommentID"]); if (commentID == 0) { comment = new CarrierComment(); comment.CarrierID = carrierID; comment.CommentDate = DateTime.Now; comment.Status = true; } comment.CommentText = txtComment.Text.Trim(); comment.UserId = Core.SessionHelper.getUserId(); try { CarrierCommentManager.Save(comment); bindComments(); showGridPanel(); lblMessage.Text = "Comment saved successfully."; lblMessage.CssClass = "ok"; } catch (Exception ex) { lblMessage.Text = "Comment not saved successfully."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } }
private void bindComments() { gvComments.DataSource = CarrierCommentManager.GetAll(carrierID); gvComments.DataBind(); }