protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { YMC.BLL.News news = new YMC.BLL.News(); news.LoadAll(); news.Query.Top = 5; uiRepeaterNews.DataSource = news.DefaultView; uiRepeaterNews.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["nid"] != null && !string.IsNullOrEmpty(Request.QueryString["nid"])) { uiPanelAllNews.Visible = false; uiPanelViewNews.Visible = true; int id = Convert.ToInt32(Request.QueryString["nid"].ToString()); YMC.BLL.News currentnews = new YMC.BLL.News(); currentnews.LoadByPrimaryKey(id); uiLabelTitle.Text = currentnews.Title; uiLiteralContent.Text = Server.HtmlDecode(currentnews.Details); } else { uiPanelAllNews.Visible = true; uiPanelViewNews.Visible = false; BindData(); } } }
private void BindData() { YMC.BLL.News currentnews = new YMC.BLL.News(); currentnews.LoadAll(); currentnews.DefaultView.Sort = "NewsDate desc"; PagedDataSource pds = new PagedDataSource(); pds.DataSource = currentnews.DefaultView; pds.AllowPaging = true; pds.PageSize = 10; pds.CurrentPageIndex = currentPage; uiRepeaterNews.DataSource = pds; uiRepeaterNews.DataBind(); uiLinkButtonPrev.Enabled = true; uiLinkButtonNext.Enabled = true; if (currentPage == 0) { uiLinkButtonPrev.Enabled = false; } if (currentPage == (pds.PageCount - 1)) { uiLinkButtonNext.Enabled = false; } }