Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            tempService = new TempService(this);
            if (!IsPostBack)
            {
                if (NewsID == -1)
                {
                    var Data = IB.Common.Base.V_Base.Data;

                    var news = from nw in Data.CV_News
                               join cat_ in Data.CV_CatNews on nw.CatNewsID
                               equals cat_.CatID
                               where (nw.CatNewsID == CatID || CatID == -1) && cat_.PortalID == PortalId
                               orderby nw.NewsID descending
                               select
                               new NewsInfo {
                        Content      = nw.Content,
                        CreatedDate  = nw.CreatedDate.Value,
                        ImageName    = nw.ImageName,
                        NewsId       = nw.NewsID,
                        ShortContent = nw.ShortContent,
                        Title        = nw.Title,
                        Url          = WriteUrl(TabId.ToString(), "detailnews", nw.NewsID.ToString(), nw.Title)
                    };

                    //1 . chuyen truy van thanh list
                    IB.Paging.PagedList <NewsInfo> pl = new IB.Paging.PagedList <NewsInfo>(news, PageCurr - 1, PageSize);
                    //2 . gan vao repeater
                    if (pl.Count > 0)
                    {
                        rptnews.DataSource = pl;
                        rptnews.DataBind();
                        //3 . chuyen thanh thanh phan trang
                        IB.Paging.Pager pg = new IB.Paging.Pager(PageSize, PageCurr, pl.TotalItemCount, TabId);
                        //4. tao thanh phan trang
                        pnPaging.Text = pg.RenderHtml();
                    }
                    mv.SetActiveView(vList);
                }
                else
                {
                    NewsDetail c = (NewsDetail)Page.LoadControl(ControlPath + "/NewsDetail.ascx");
                    c.ListNews    = this;
                    c.TempService = this.tempService;
                    c.DataBinding();
                    plhDetail.Controls.Add(c);
                    mv.SetActiveView(vDetail);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            tempService=new TempService(this);
            if (!IsPostBack)
            {
                if (NewsID == -1)
                {
                    var Data = IB.Common.Base.V_Base.Data;

                    var news = from nw in Data.CV_News
                               join cat_ in Data.CV_CatNews on nw.CatNewsID
                                   equals cat_.CatID
                               where (nw.CatNewsID == CatID || CatID == -1) && cat_.PortalID == PortalId
                               orderby nw.NewsID descending
                               select
                                   new NewsInfo{
                                           Content = nw.Content,
                                           CreatedDate = nw.CreatedDate.Value,
                                           ImageName = nw.ImageName,
                                           NewsId = nw.NewsID,
                                           ShortContent = nw.ShortContent,
                                           Title = nw.Title,
                                           Url = WriteUrl(TabId.ToString(), "detailnews",nw.NewsID.ToString(),nw.Title)
                                       };

                    //1 . chuyen truy van thanh list
                    IB.Paging.PagedList<NewsInfo> pl = new IB.Paging.PagedList<NewsInfo>(news, PageCurr - 1, PageSize);
                    //2 . gan vao repeater
                    if (pl.Count > 0)
                    {
                        rptnews.DataSource = pl;
                        rptnews.DataBind();
                        //3 . chuyen thanh thanh phan trang
                        IB.Paging.Pager pg = new IB.Paging.Pager(PageSize, PageCurr, pl.TotalItemCount, TabId);
                        //4. tao thanh phan trang
                        pnPaging.Text = pg.RenderHtml();
                    }
                    mv.SetActiveView(vList);
                }
                else
                {
                    NewsDetail c = (NewsDetail)Page.LoadControl(ControlPath + "/NewsDetail.ascx");
                    c.ListNews = this;
                    c.TempService = this.tempService;
                    c.DataBinding();
                    plhDetail.Controls.Add(c);
                    mv.SetActiveView(vDetail);
                }
            }
        }