Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Context.Items["strTitle"] = "DANH SÁCH TIN TỨC, BÀI VIẾT";

        if (!Page.IsPostBack)
        {
            DataNewsGroup objGroup = new DataNewsGroup();
            ddlGroup.DataSource     = objGroup.getDataToCombobox("Tất cả");
            ddlGroup.DataValueField = "ID";
            ddlGroup.DataTextField  = "NAME";
            ddlGroup.DataBind();

            ddlGroup.SelectedValue = "0";
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.itemId = int.Parse(Request["id"].ToString());
        }
        catch { }

        if (!Page.IsPostBack)
        {
            DataNewsGroup objGroup = new DataNewsGroup();
            ddlGroup.DataSource     = objGroup.getDataToCombobox("");
            ddlGroup.DataValueField = "ID";
            ddlGroup.DataTextField  = "NAME";
            ddlGroup.DataBind();
        }

        if (!Page.IsPostBack && this.itemId != 0)
        {
            DataRow objData = objNews.getData(this.itemId);
            if (objData == null)
            {
                objSystemClass.addMessage("Bạn cần chọn nhóm để sửa.");
                Response.Redirect("NewsList.aspx");
                return;
            }

            txtTitle.Text          = objData["Title"].ToString();
            ddlGroup.SelectedValue = objData["CatId"].ToString();
            txtShortContent.Text   = objData["ShortContent"].ToString();
            txtContent.Text        = objData["Content"].ToString();
            txtAuthor.Text         = objData["Author"].ToString();
            ckbNoiBat.Checked      = (bool)objData["NoiBat"];
            txtTag.Text            = objData["tag"].ToString();

            if (objData["ImgUrl"] != null && objData["ImgUrl"].ToString() != "")
            {
                htxtimg.Value = "/Images/News/" + objData["ImgUrl"].ToString();
            }
        }
    }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.itemId = int.Parse(getParam("id"));
        }
        catch { }

        try
        {
            this.sapXep = (getParam("sapxep") != "1") ? "DESC" : "ASC";
        }
        catch { }

        try
        {
            this.page = int.Parse(Request["page"].ToString());
        }
        catch { }



        if (!Page.IsPostBack)
        {
            #region phan trang
            maxitem = objNews.getDataCount(itemId);
            maxPage = maxitem / numItem;
            if (maxitem % numItem > 0 || maxPage == 0)
            {
                maxPage++;
            }
            if (page > maxPage)
            {
                page = maxPage;
            }
            if (page < 1)
            {
                page = 1;
            }

            String link = "";
            if (itemId != 0)
            {
                link = "&id=" + itemId;
            }
            if (sapXep == "ASC")
            {
                link += "&sapxep=1";
            }
            //link += "#listnews";

            if (page - 1 >= 1)
            {
                pager.Add(new PageData("Trước", "?page=" + (page - 1) + link));
            }
            if (page != 1)
            {
                pager.Add(new PageData("1", "?page=1" + link));
            }

            int a = page - 5;
            if (a < 2)
            {
                a = 2;
            }
            for (int i = a; i < page; i++)
            {
                pager.Add(new PageData(i.ToString(), "?page=" + i + link));
            }

            pager.Add(new PageData(page.ToString(), "#", true));

            a = page + 5;
            if (a > maxPage)
            {
                a = maxPage;
            }
            for (int i = page + 1; i < a; i++)
            {
                pager.Add(new PageData(i.ToString(), "?page=" + i + link));
            }

            if (page != maxPage)
            {
                pager.Add(new PageData(maxPage.ToString(), "?page=" + maxPage + link));
            }
            if (page + 1 <= maxPage)
            {
                pager.Add(new PageData("Sau", "?page=" + (page + 1) + link));
            }
            #endregion
            //ddlpager.DataSource = pager;
            //ddlpager.DataBind();

            DataTable objData = objNews.getDataTop(numItem, itemId, page, false, "", sapXep);


            DanhSachTin.BindData(objData);

            DataNewsGroup objGroup = new DataNewsGroup();
            if (itemId != 0)
            {
                groupname = objGroup.getNameById(itemId);
            }
            else
            {
                groupname = "Tin Tức";
            }

            Context.Items["strTitle"] = groupname;
        }
    }