예제 #1
0
        private void BindDataGrid(bool dataBind)
        {
            DataView dv = EMailMessage.GetPendingMessages().DefaultView;

            grdMain.DataSource = dv;

            if (dataBind)
            {
                grdMain.DataBind();
            }
        }
예제 #2
0
        private void BindDataGrid()
        {
            int i = 1;

            dgPendMess.Columns[i++].HeaderText = "ID";
            dgPendMess.Columns[i++].HeaderText = LocRM.GetString("tSubject");
            dgPendMess.Columns[i++].HeaderText = LocRM.GetString("tFrom");
            dgPendMess.Columns[i++].HeaderText = LocRM.GetString("tTo");
            dgPendMess.Columns[i++].HeaderText = LocRM.GetString("tCreated");
            foreach (DataGridColumn dgc in dgPendMess.Columns)
            {
                if (dgc.SortExpression == pc["emr_PendMess_Sort"].ToString())
                {
                    dgc.HeaderText += "&nbsp;<img border='0' align='absmiddle' width='9px' height='5px' src='" + this.Page.ResolveUrl("~/layouts/images/upbtnF.jpg") + "'/>";
                }
                else if (dgc.SortExpression + " DESC" == pc["emr_PendMess_Sort"].ToString())
                {
                    dgc.HeaderText += "&nbsp;<img border='0' align='absmiddle' width='9px' height='5px' src='" + this.Page.ResolveUrl("~/layouts/images/downbtnF.jpg") + "'/>";
                }
            }

            /*			DataTable dt = new DataTable();
             * dt.Columns.Add(new DataColumn("PendingMessageId", typeof(int)));
             * dt.Columns.Add(new DataColumn("From", typeof(string)));
             * dt.Columns.Add(new DataColumn("To", typeof(string)));
             * dt.Columns.Add(new DataColumn("Subject", typeof(string)));
             * dt.Columns.Add(new DataColumn("Created", typeof(DateTime)));
             * DataRow dr;
             * int[] pendList = EMailMessage.ListPendigEMailMessageIds();
             * foreach(int id in pendList)
             * {
             *      dr = dt.NewRow();
             *      dr["PendingMessageId"] = id;
             * //				EMailMessageInfo emi = EMailMessageInfo.Load(id);
             * //				dr["From"] = GetAddress(emi.From);
             * //				dr["To"] = GetAddress(emi.To);
             * //				dr["Subject"] = emi.Subject;
             * //				dr["Created"] = emi.Created;
             *      dt.Rows.Add(dr);
             * }
             * DataView dv = dt.DefaultView;
             */
            DataView dv = EMailMessage.GetPendingMessages().DefaultView;

            dv.Sort = pc["emr_PendMess_Sort"].ToString();

            dgPendMess.DataSource = dv;

            if (pc["emr_PendMess_PageSize"] != null)
            {
                dgPendMess.PageSize = int.Parse(pc["emr_PendMess_PageSize"].ToString());
            }

            if (pc["emr_PendMess_Page"] != null)
            {
                int iPageIndex = int.Parse(pc["emr_PendMess_Page"].ToString());
                int ppi        = dv.Count / dgPendMess.PageSize;
                if (dv.Count % dgPendMess.PageSize == 0)
                {
                    ppi = ppi - 1;
                }
                if (iPageIndex <= ppi)
                {
                    dgPendMess.CurrentPageIndex = iPageIndex;
                }
                else
                {
                    dgPendMess.CurrentPageIndex = 0;
                }
            }
            dgPendMess.DataBind();

            foreach (DataGridItem dgi in dgPendMess.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibDelete");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tWarningDelete") + "')");
                    ib.Attributes.Add("title", LocRM.GetString("tDelete"));
                }
                ImageButton ib1 = (ImageButton)dgi.FindControl("ibApprove");
                if (ib1 != null)
                {
                    ib1.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tWarningApprove") + "')");
                    ib1.Attributes.Add("title", LocRM.GetString("tApprove"));
                }
            }
        }