protected void rbTnSearchGvInbox_Click(object sender, EventArgs e)
        {
            RadTextBox RtxtSearchGvInbox;

            foreach (GridFilteringItem filterItem in RgvInbox.MasterTableView.GetItems(GridItemType.FilteringItem))
            {
                RtxtSearchGvInbox = (RadTextBox)filterItem.FindControl("RtxtSearchGvInbox");
                string    searchvalue             = Convert.ToString(RtxtSearchGvInbox.Text);
                DataTable dtStudentLeadInboxEmail = new DataTable();
                dtStudentLeadInboxEmail = (DataTable)Session["dtStudentLeadInboxEmail"];
                dtStudentLeadInboxEmail = dtStudentLeadInboxEmail.Select("EmailSubject LIKE \'%" + searchvalue + "%\' ").CopyToDataTable();
                RgvInbox.DataSource     = dtStudentLeadInboxEmail;
                RgvInbox.DataBind();
            }
        }
        protected void ItemChkboxEmailIsRead_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
                bool checkHeader = true;
                foreach (GridDataItem dataItem in RgvInbox.MasterTableView.Items)
                {
                    if ((dataItem.FindControl("ItemChkboxEmailIsRead") as CheckBox).ClientID == (sender as CheckBox).ClientID)
                    {
                        string InboxID = Convert.ToString((dataItem.Cells[0].FindControl("ItemLblInboxID") as Label).Text);
                        string strchk  = "";
                        if ((sender as CheckBox).Checked == true)
                        {
                            strchk = "true";
                        }
                        else
                        {
                            strchk = "false";
                        }
                        DataAccessManager.GetUpdateUnread(InboxID, strchk);

                        if (Source.SOrL(Convert.ToString(Session["StudentNo"]), Convert.ToString(Session["leadID"])))
                        {
                            RgvInbox.Rebind();
                            //StudentInboxEmail();

                            checkHeader = false;
                            break;
                        }
                        else
                        {
                            RgvInbox.Rebind();
                            //StudentInboxEmail();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected void RgvInbox_ItemCommand(object sender, GridCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "download_fileInbox")
                {
                    GridNestedViewItem ditem    = (GridNestedViewItem)e.Item;
                    string             filename = e.CommandArgument.ToString();
                    if (filename != "No")
                    {
                        if (filename != "Not Available")
                        {
                            string FolderName = string.Empty;
                            FolderName = Convert.ToString(Session["CampusName"]);
                            string path = MapPath("~/InboxAttachment/" + FolderName + "/" + filename);
                            byte[] bts  = System.IO.File.ReadAllBytes(path);
                            Response.Clear();
                            Response.ClearHeaders();
                            Response.AddHeader("Content-Type", "Session/octet-stream");
                            Response.AddHeader("Content-Length", bts.Length.ToString());
                            Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
                            Response.BinaryWrite(bts);
                            Response.Flush();
                            Response.End();
                            return;
                        }
                    }
                }


                if (e.CommandName == RadGrid.ExpandCollapseCommandName && !e.Item.Expanded)
                {
                    GridDataItem ditem = (GridDataItem)e.Item;
                    HiddenField  hdn   = (HiddenField)ditem.ChildItem.FindControl("hdnInboxID");
                    //  string s = ditem.ChildItem.OwnerTableView.ParentItem.GetDataKeyValue("InboxID").ToString();
                    string  inboxid = hdn.Value;
                    Boolean result  = false;
                    result = DataAccessManager.GetUpdateUnread(inboxid, "true");
                    if (result == true)
                    {
                        GridDataItem item                  = (GridDataItem)e.Item;
                        Label        EmailReceived         = item.FindControl("EmailReceived") as Label;
                        Label        EmailSubject          = item.FindControl("EmailSubject") as Label;
                        Label        EmailReceivedDatetime = item.FindControl("EmailReceivedDatetime") as Label;
                        Label        Attachment            = item.FindControl("Attachment") as Label;
                        CheckBox     chkBoolean            = item.FindControl("ItemChkboxEmailIsRead") as CheckBox;
                        EmailSubject.ForeColor          = System.Drawing.Color.Blue;
                        chkBoolean.Checked              = true;
                        EmailReceived.Font.Bold         = false;
                        EmailSubject.Font.Bold          = false;
                        Attachment.Font.Bold            = false;
                        EmailReceivedDatetime.Font.Bold = false;
                    }
                }


                if (e.CommandName == "DeleteInboxstdleademail")
                {
                    GridDataItem ditem = (GridDataItem)e.Item;
                    e.Item.Selected = true;
                    string  DeleteID = e.CommandArgument.ToString();
                    Boolean result   = false;
                    result = DataAccessManager.GetDeleteStdLeadInbox(DeleteID);
                    if (result == true)
                    {
                        if (Source.SOrL(Convert.ToString(Session["StudentNo"]), Convert.ToString(Session["leadID"])))
                        {
                            StudentInboxEmail();
                        }
                        else
                        {
                            LeadInboxEmail();
                        }
                        RgvInbox.Rebind();
                    }
                }

                if (e.CommandName == "imgbtnreplystd")
                {
                    GridDataItem ditem           = (GridDataItem)e.Item;
                    Label        EmailReceived   = (Label)ditem.FindControl("EmailReceived");
                    Label        EmailSubject    = (Label)ditem.FindControl("EmailSubject");
                    Label        lbdeptEmailBody = (Label)ditem.FindControl("lblstdEmailBody");
                    //Rtxtemailto.Text = EmailReceived.Text;
                    //RtxtemailSubject.Text = "Re:" + EmailSubject.Text;
                    //REditComposeBody.Content = "<br/><br/>-----------------------------------------------------<br/>" + lbdeptEmailBody.Text;

                    Session["ReplyStdLeadEmailTo"]          = EmailReceived.Text;
                    Session["ReplyStdLeadEmailSubject"]     = "Re:" + EmailSubject.Text;
                    Session["ReplyStdLeadEmailComposeBody"] = "<br/><br/>-----------------------------------------------------<br/>" + lbdeptEmailBody.Text;
                    Response.Redirect("~/frmstudentleadcomposeemaill.aspx", false);
                }
            }
            catch (Exception ex)
            {
                //
            }
        }