public void BindRecord(string searchby, int pageS)
    {
        try
        {
            con = new SqlConnection(ConfigurationManager.ConnectionStrings["Ad_ConnectionStringMain"].ToString());
            SqlCommand cmd = new SqlCommand("GetSearchFromMasterPage", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@PageIndex", 1);
            cmd.Parameters.AddWithValue("@PageSize", pageS);
            cmd.Parameters.AddWithValue("@RecordCount", "");
            cmd.Parameters.AddWithValue("@Searchby", searchby);

            SqlDataAdapter daP = new SqlDataAdapter(cmd);
            DataTable dtProduct = new DataTable();
            daP.Fill(dtProduct);
            clsAssignDataCollection getVW_Item = new clsAssignDataCollection();

            uc_VwProduct1.ProductItemBind(getVW_Item.GetViewProductCommon(dtProduct.ToList<vw_OfferItem>()));
            //if (dtProduct.Rows.Count > 0)
            //    lnkLoadmoreRecords.Visible = true;
            //else
            //    lnkLoadmoreRecords.Visible = false;
            //ViewState["NoofProduct"] = dtProduct;
        }
        catch (Exception ex)
        { }
    }
Exemple #2
0
    public void BindDatasetRecordSet()
    {
        DataTable dtDatasetResult = (DataTable)ViewState["DatasetResult"];

        ViewState["TotalPages"] = (Convert.ToInt32(dtDatasetResult.Rows.Count) / pageSize) + 1;
        clsAssignDataCollection getVW_Item = new clsAssignDataCollection();
        DataTable dt = objSearch.FunctionForPaging(dtDatasetResult, CurrentPage, pageSize);

        uc_VwProduct1.ProductItemBind(getVW_Item.GetViewProductCommon(dt.ToList <vw_OfferItem>()));
        PagingInRepeater();
    }
    public void BindRecord(string sortby)
    {
        try
        {
            DataTable dtprice = new DataTable();
            dtprice.Columns.Add("HighPrice");
            dtprice.Columns.Add("LowPrice");
            if (txtPriceTo.Text != string.Empty && txtpriceFrom.Text != string.Empty)
            {
                DataRow drPrice = dtprice.NewRow();
                drPrice["HighPrice"] = txtPriceTo.Text;
                drPrice["LowPrice"]  = txtpriceFrom.Text;
                dtprice.Rows.Add(drPrice);
            }


            DataTable dtp = new DataTable();
            dtp        = BindAllBrand();
            dtMerchant = new DataTable();
            dtMerchant.Columns.Add("merchantID");
            dtMerchant.Columns.Add("merchantName");
            foreach (ListItem lstMerchat in chkMerchant.Items)
            {
                if (lstMerchat.Selected)
                {
                    DataRow dr = dtMerchant.NewRow();
                    dr["merchantID"] = lstMerchat.Value;
                    string input = string.Empty;
                    int    index = lstMerchat.Text.LastIndexOf("(");
                    if (index > 0)
                    {
                        input = lstMerchat.Text.Substring(0, index - 1);
                    }
                    dr["merchantName"] = input;
                    dtMerchant.Rows.Add(dr);
                }
            }

            dtCategory = new DataTable();
            dtCategory.Columns.Add("CategoryID_N");
            dtCategory.Columns.Add("CategoryName_V");

            foreach (ListItem lstCategory in chkCategory.Items)
            {
                if (lstCategory.Selected)
                {
                    DataRow dr = dtCategory.NewRow();
                    dr["CategoryID_N"] = lstCategory.Value;
                    string input = string.Empty;
                    int    index = lstCategory.Text.LastIndexOf("(");
                    if (index > 0)
                    {
                        input = lstCategory.Text.Substring(0, index - 1);
                    }
                    dr["CategoryName_V"] = input;
                    dtCategory.Rows.Add(dr);
                }
            }

            SqlCommand cmd = new SqlCommand("GetOfferItemPageWiseSearchForBrand", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@PageIndex", 1);
            cmd.Parameters.AddWithValue("@PageSize", pageSize);
            cmd.Parameters.AddWithValue("@RecordCount", "");
            cmd.Parameters.AddWithValue("@categoryName_V", dtCategory);
            cmd.Parameters.AddWithValue("@Brandname", dtp);
            cmd.Parameters.AddWithValue("@MerchantName", dtMerchant);
            cmd.Parameters.AddWithValue("@searchType", "");
            cmd.Parameters.AddWithValue("@sortby", sortby);
            cmd.Parameters.AddWithValue("@price", dtprice);

            SqlDataAdapter daP       = new SqlDataAdapter(cmd);
            DataTable      dtProduct = new DataTable();
            daP.Fill(dtProduct);
            this.lblPageInfo.Text = "Page " + (CurrentPage + 1) + " of " + ViewState["TotalPages"].ToString();
            if (CurrentPage == 0 && Convert.ToInt32(ViewState["TotalPages"]) * pageSize > pageSize)
            {
                lbtnPrevious.Enabled = false;
                lbtnNext.Enabled     = true;
                lbtnFirst.Enabled    = false;
                lbtnLast.Enabled     = true;
            }
            else if (CurrentPage == 0 && Convert.ToInt32(ViewState["TotalPages"]) * pageSize <= pageSize)
            {
                lbtnPrevious.Enabled = false;
                lbtnNext.Enabled     = false;
                lbtnFirst.Enabled    = false;
                lbtnLast.Enabled     = false;
            }
            else if (Convert.ToInt32(ViewState["TotalPages"]) == CurrentPage + 1)
            {
                lbtnPrevious.Enabled = true;
                lbtnNext.Enabled     = false;
                lbtnFirst.Enabled    = true;
                lbtnLast.Enabled     = false;
            }
            else
            {
                lbtnPrevious.Enabled = true;
                lbtnNext.Enabled     = true;
                lbtnFirst.Enabled    = true;
                lbtnLast.Enabled     = true;
            }
            clsAssignDataCollection getVW_Item = new clsAssignDataCollection();

            uc_VwProduct1.ProductItemBind(getVW_Item.GetViewProductCommon(dtProduct.ToList <vw_OfferItem>()));
            doPaging();
        }
        catch (Exception ex)
        { }
    }