protected void grdMessages_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int colIndex = GetGridViewColumnIndex(grdMessages.Columns, GvColumnReadDate);
            if (hidFolder.Value == PrivateMessagesManager.Folders.Inbox)
            {
                if (colIndex >= 0)
                {
                    if (e.Row.Cells[colIndex].Text == NullDisplayText)
                    {
                        foreach (TableCell cell in e.Row.Cells)
                        {
                            cell.Font.Bold = true;
                        }
                    }
                }
            }

            e.Row.Attributes[HtmlAttributeOnMouseOver] = JavascriptOnMouseOver;
            e.Row.Attributes[HtmlAttributeOnMouseOut]  = JavascriptOnMouseOut;

            colIndex = GetGridViewColumnIndex(grdMessages.Columns, GvColumnId);
            if (colIndex >= 0)
            {
                e.Row.Attributes[HtmlAttributeOnMouseClick] = string.Format(JavascriptViewMessage, e.Row.Cells[colIndex].Text);
            }

            colIndex = GetGridViewColumnIndex(grdMessages.Columns, GvColumnSentdateHeader);
            if (colIndex >= 0)
            {
                DateTime sentDate = DateTime.Parse(e.Row.Cells[colIndex].Text);
                e.Row.Cells[colIndex].Text = PrivateMessagesManager.FormatDateForDisplay(sentDate);
            }
        }
    }
    private void OpenPrivateMessage(string privateMessageId)
    {
        ResetAll();
        divList.Visible           = false;
        hidPrivateMessageId.Value = privateMessageId;

        PrivateMessage msg = PrivateMessagesManager.GetPrivateMessage(privateMessageId);

        if (msg != null)
        {
            User currentUser = MembershipManager.GetUserByName(Page.User.Identity.Name);
            if (currentUser.Id == msg.Recipient.Id || currentUser.Id == msg.Sender.Id)
            {
                if (msg.ReadDate == null)
                {
                    PrivateMessagesManager.MarkAsRead(msg);
                }

                divViewPrivateMessage.Visible = true;

                lblDateSent.Text = PrivateMessagesManager.FormatDateForDisplay(msg.SentDate);
                lblTo.Text       = msg.Recipients;
                lblFrom.Text     = msg.Sender.Name;
                lblSubject.Text  = msg.Subject;
                txtBody.Text     = msg.Body;
            }
            else
            {
                ((IFeedback)Page.Master).SetError(GetType(), ErrorPermissionDenied);
            }
        }
        else
        {
            ((IFeedback)Page.Master).SetError(GetType(), ErrorUnableToOpen);
        }
    }