Exemplo n.º 1
0
    public void BindData()
    {
        StoreFront ObjService = new StoreFront();
        DataSet    DS         = new DataSet();

        DS = ObjService.GetFriendSearch(Request.QueryString["Key"].ToString());
        try
        {
            if (DS.Tables[0].Rows.Count > 0)
            {
                lblTitleFriend.Text = "Fritzy's Pet Care Pros friends listing :";
                int currpage;
                PageDs_Friend.DataSource  = DS.Tables[0].DefaultView;
                PageDs_Friend.AllowPaging = true;
                PageDs_Friend.PageSize    = 10;

                if (ViewState["CurrentPage_Friend"] != null)
                {
                    currpage = Convert.ToInt32(ViewState["CurrentPage_Friend"]);
                }
                else
                {
                    currpage = 1;
                }
                ViewState["CurrentPage_Friend"] = currpage;
                PageDs_Friend.CurrentPageIndex  = currpage - 1;

                bool check = false;
                if (PageDs_Friend.IsFirstPage)
                {
                    check = true;
                    lnkFriendNext.Visible = true;
                }
                else if (PageDs_Friend.IsLastPage)
                {
                    check = true;
                    lnkFriendNext.Visible = false;
                }
                if (PageDs_Friend.PageCount == 1)
                {
                    lnkFriendNext.Visible  = false;
                    lnkFriendNext.CssClass = "linkDisable";
                }
                else if (PageDs_Friend.PageCount > 1 && check == false)
                {
                    lnkFriendNext.Visible = true;
                }


                if (DS.Tables[0].Rows.Count == 0)
                {
                    dlFriends.Visible = false;
                }
                else
                {
                    Session["PDSAllFriends"] = PageDs_Friend;
                    dlFriends.DataSource     = PageDs_Friend;
                    dlFriends.DataBind();
                }
                if (lnkFriendNext.Visible == true)
                {
                    lblFriendLine.Visible = true;
                }
                else
                {
                    lblFriendLine.Visible = false;
                }
            }
            else
            {
                dlFriends.Visible      = false;
                prevFriendlink.Visible = false;
                lnkFriendNext.Visible  = false;
                lblFriendLine.Visible  = false;
                lblTitleFriend.Text    = "No record found.";
            }
        }
        catch (IndexOutOfRangeException ex)
        {
            throw ex;
        }
    }