コード例 #1
0
ファイル: CamNhan_Home.ascx.cs プロジェクト: coltechvn/SolArt
        protected void rptData_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                var curData     = (DataRowView)e.Item.DataItem;
                var litName     = (Literal)e.Item.FindControl("litName");
                var litTeaser   = (Literal)e.Item.FindControl("litTeaser");
                var litDatetime = (Literal)e.Item.FindControl("litDatetime");
                var imgAvatar   = (Image)e.Item.FindControl("imgAvatar");

                litName.Text   = curData["Content_Name"].ToString();
                litTeaser.Text = curData["Content_Teaser"].ToString();

                litDatetime.Text = ConvertUtility.ToDateTime(curData["Distribution_CreateDate"]).ToString("dd MMMM yyyy");

                var coverInfo = ImageDB.GetCover(ConvertUtility.ToInt32(curData["Content_ID"]));
                if (coverInfo != null)
                {
                    var avatar = coverInfo.Image_File;
                    if (avatar.Length > 0)
                    {
                        imgAvatar.ImageUrl = UrlFilter.BuildImageScaleHeight(avatar, 0, 50);
                    }
                    else
                    {
                        imgAvatar.Visible = false;
                    }
                }
                else
                {
                    imgAvatar.Visible = false;
                }
            }
        }