protected void grvMails_RowDeleting(object sender, GridViewDeleteEventArgs e) { string messageId = (string)this.grvMails.DataKeys[e.RowIndex].Value; MailMessageServices services = new MailMessageServices(); string accountId = Request.QueryString["AccountId"]; string userId = Request.QueryString["UserId"]; services.DeleteMailMessageOfAccount(userId, accountId, messageId); this.Bind(); }
private void Bind() { string accountId = Request.QueryString["AccountId"]; if (accountId == null) { lblError.Text = "Account Id not specified. Back to mailbox"; lblError.Visible = true; pnlMail.Visible = false; return; } string userId = Request.QueryString["UserId"]; if (userId == null) { lblError.Text = "User Id not specified. Back to mailbox"; lblError.Visible = true; pnlMail.Visible = false; return; } UserServices userService = new UserServices(); User currentUser = userService.GetUserByUsername(Context.User.Identity.Name); if (currentUser.Id != userId) { Response.Redirect("MailboxAccount.aspx"); return; } MailMessageServices services = new MailMessageServices(); IList<MailMessage> messages = services.GetMailMessagesOfAccount(userId, accountId); this.grvMails.DataSource = messages; this.grvMails.DataBind(); this.grvMails.Visible = (this.grvMails.DataSource as IList).Count > 0; this.lblNoMessage.Visible = (this.grvMails.DataSource as IList).Count == 0; }