コード例 #1
0
        private void BindArticle(int articleId)
        {
            lblInvalidCategory.Visible = false;
            ArticleInfo objArticle = ArticleController.Get(articleId);

            if (objArticle == null)
            {
                return;
            }


            txtTitle.Text    = objArticle.Title;
            txtAuthor.Text   = objArticle.Author;
            txtSource.Text   = objArticle.Source;
            chkQuote.Checked = objArticle.Quote;
            txtPinOrder.Text = Convert.ToString(objArticle.PinOrder);
            chkDraft.Checked = objArticle.Draft;

            ctlLinkUrl.Url      = objArticle.LinkUrl;
            chkFeatured.Checked = objArticle.Featured;
            chkAuthed.Checked   = objArticle.Authed;
            chkActive.Checked   = objArticle.Active;

            //Image

            if (UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
            {
                ctlImage.Url = objArticle.Image;
            }
            else
            {
                ctlUserImage.Url = objArticle.Image;
            }
            txtImageDescription.Text = objArticle.ImageDescription;
            RecursiveHelper.FillAspNetTreeCheckBox(ref tvCategory, objArticle.Categories, true);

            List <ArticleToTagInfo> tags = (from t in ArticleToTagController.ListByArticle(articleId) select t).ToList();

            txtTag1.Text  = tags.Count > 0 ? tags[0].Tag : "";
            txtTag2.Text  = tags.Count > 1 ? tags[1].Tag : "";
            txtTag3.Text  = tags.Count > 2 ? tags[2].Tag : "";
            txtTag4.Text  = tags.Count > 3 ? tags[3].Tag : "";
            txtTag5.Text  = tags.Count > 4 ? tags[4].Tag : "";
            txtTag6.Text  = tags.Count > 5 ? tags[5].Tag : "";
            txtTag7.Text  = tags.Count > 6 ? tags[6].Tag : "";
            txtTag8.Text  = tags.Count > 7 ? tags[7].Tag : "";
            txtTag9.Text  = tags.Count > 8 ? tags[8].Tag : "";
            txtTag10.Text = tags.Count > 9 ? tags[9].Tag : "";

            //Date
            if (!Null.IsNull(objArticle.PublishDate))
            {
                txtPublishDate.Text = objArticle.PublishDate.ToShortDateString();
            }
            if (!Null.IsNull(objArticle.ExpireDate))
            {
                txtExpireDate.Text = objArticle.ExpireDate.ToShortDateString();
            }

            cblViewRoles = Utils.FillRolesCheckBox(cblViewRoles, objArticle.ViewRoles, PortalSettings.AdministratorRoleId, PortalId);

            //rating
            chkAllowRating.Checked = objArticle.AllowRating;
            cblRatingRoles         = Utils.FillRolesCheckBox(cblRatingRoles, objArticle.RatingRoles, PortalSettings.AdministratorRoleId, PortalId);

            //Comment value
            chkAllowComment.Checked    = objArticle.AllowComment;
            chkAutoAuthComment.Checked = objArticle.AutoAuthComment;
            cblCommentRoles            = Utils.FillRolesCheckBox(cblCommentRoles, objArticle.CommentRoles, PortalSettings.AdministratorRoleId, PortalId);

            //
            chkAllowRecommend.Checked = objArticle.AllowRecommend;
            cblRecommendRoles         = Utils.FillRolesCheckBox(cblRecommendRoles, objArticle.RecommendRoles, PortalSettings.AdministratorRoleId, PortalId);

            cblDownloadRoles = Utils.FillRolesCheckBox(cblDownloadRoles, objArticle.DownloadRoles, PortalSettings.AdministratorRoleId, PortalId);



            txtSummary.Text = objArticle.Summary;
            txtDetail.Text  = Server.HtmlDecode(objArticle.Article);

            AttachmentList = new List <AttachmentInfo>();
            List <AttachmentInfo> aiList = AttachmentController.ListByArticle(articleId);

            for (int i = 0; i < aiList.Count; i++)
            {
                AttachmentInfo ai = new AttachmentInfo();
                ai.Id        = i;
                ai.ArticleId = articleId;
                ai.FilePath  = aiList[i].FilePath;
                AttachmentList.Add(ai);
            }

            gvAttachment.DataSource = AttachmentList;
            gvAttachment.DataBind();
        }