Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dtNewsCategory = taNewsCategory.SelectNewsCategoryNameByNewsCategoryId(5);
            if (dtNewsCategory.Rows.Count > 0)
            {
                int page = 10;

                dtNews = taNews.SelectNewsbyNewsCategoryId(5);
                if (dtNews.Rows.Count > 0)
                {
                    PagedDataSource objPds = new PagedDataSource();
                    objPds.DataSource = dtNews.DefaultView;
                    objPds.AllowPaging = true;
                    objPds.PageSize = page;
                    objPds.CurrentPageIndex = CurrentPage;
                    Repeater1.DataSource = objPds;
                    Repeater1.DataBind();
                }
                else
                {
                    Repeater1.Visible = false;
                }
            }
            else
            {
                Repeater1.Visible = false;
            }
    }
Esempio n. 2
0
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton btnDel = (LinkButton)e.Row.FindControl("delbutton");
            btnDel.Attributes.Add("OnClick", "return confirm('Are you sure to delete this record?');");

            Label lblNewsCategoryId = (Label)e.Row.FindControl("lblNewsCategoryId");
            dtNewsCategory = taNewsCategory.SelectNewsCategoryNameByNewsCategoryId(Convert.ToInt32(lblNewsCategoryId.Text));
            if (dtNewsCategory.Rows.Count > 0)
                lblNewsCategoryId.Text = dtNewsCategory[0].NewsCategoryTitle.ToString();

        }
    }
    private void ItemsGet()
    {
        if (Request.QueryString["NewsCategoryId"] != null)
        {

            int NewsCategoryId = Convert.ToInt32(Request.QueryString["NewsCategoryId"]);
            dtNewsCategory = taNewsCategory.SelectNewsCategoryNameByNewsCategoryId(NewsCategoryId);
            if (dtNewsCategory.Rows.Count > 0)
            {
                int page = 10;
                lblCategoryName.Text = dtNewsCategory[0].NewsCategoryTitle.ToString();
                dtNews = taNews.SelectNewsbyNewsCategoryId(NewsCategoryId);
                if (dtNews.Rows.Count > 0)
                {
                    PagedDataSource objPds = new PagedDataSource();

                    objPds.DataSource = dtNews.DefaultView;
                    objPds.AllowPaging = true;
                    objPds.PageSize = page;

                    objPds.CurrentPageIndex = CurrentPage;
                    //objPds.CurrentPageIndex = CurrentPage - 1;

                    int count = objPds.PageCount;

                    lblCurrentPage.Text = "Page " + (CurrentPage + 1).ToString() + " of "
                       + objPds.PageCount.ToString();

                    //Disable Prev or Next buttons if necessary
                    //Button1.Visible = !objPds.IsFirstPage;
                    //Button2.Visible = !objPds.IsLastPage;
                    if (objPds.IsFirstPage)
                        Button1.Visible = false;
                    else
                        Button1.Visible = true;

                    if (objPds.IsLastPage)
                        Button2.Visible = false;
                    else
                        Button2.Visible = true;

                    Repeater1.DataSource = objPds;
                    Repeater1.DataBind();

                }
                else
                {
                    Repeater1.Visible = false;
                    Button1.Visible = false;
                    Button2.Visible = false;
                }
            }
            else
            {
                Repeater1.Visible = false;
                Button1.Visible = false;
                Button2.Visible = false;
            }
        }
        else
        {
            Repeater1.Visible = false;
            Button1.Visible = false;
            Button2.Visible = false;
        }
    }