public SearchProduct GetSearchProducts(bool IsActive, int CatId, int SubCatId, int ComnyId, int BrandId, int stateID, int DistrictId, int blockID, string technicalName, int cropID, string searh, int pageNo, int pageSize, string sortColumn, string sortColumnDir) { SearchProduct SearchPrdctList = new SearchProduct(); DataSet ds = new VideoCartDal().GetSearchProducts(IsActive, CatId, SubCatId, ComnyId, BrandId, stateID, DistrictId, cropID, blockID, technicalName, cropID, searh, pageNo, pageSize, sortColumn, sortColumnDir); if (ds != null && ds.Tables.Count > 0) { { List <SearchProductList> _SearchPrdctList = new List <SearchProductList>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { SearchProductList _Prdouct = new SearchProductList(); // _Prdouct.ROWNUM = ds.Tables[0].Rows[i]["ROWNUM"] == DBNull.Value ? 0 : Convert.ToInt64(ds.Tables[0].Rows[i]["ROWNUM"].ToString()); _Prdouct.CategoryId = ds.Tables[0].Rows[i]["CategoryId"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["CategoryId"].ToString()); _Prdouct.Company = ds.Tables[0].Rows[i]["OrganisationName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["OrganisationName"]); _Prdouct.DealerId = ds.Tables[0].Rows[i]["DealerId"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["DealerId"].ToString()); _Prdouct.DealerName = ds.Tables[0].Rows[i]["DealerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["DealerName"]); _Prdouct.ImageUrl = ds.Tables[0].Rows[i]["ImageUrl"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ImageUrl"]); _Prdouct.PackageId = ds.Tables[0].Rows[i]["packageId"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["packageId"].ToString()); _Prdouct.PackageName = ds.Tables[0].Rows[i]["Amount"].ToString() + " " + ds.Tables[0].Rows[i]["unitname"].ToString(); _Prdouct.Price = ds.Tables[0].Rows[i]["OurPrice"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i]["OurPrice"]); _Prdouct.ProductId = ds.Tables[0].Rows[i]["ProductID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["ProductID"].ToString()); _Prdouct.ProductName = ds.Tables[0].Rows[i]["ProductName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ProductName"]); _Prdouct.DistrictId = ds.Tables[0].Rows[i]["DistrictId"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["DistrictId"].ToString()); _Prdouct.DistrictName = ds.Tables[0].Rows[i]["DistrictName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["DistrictName"]); _Prdouct.VideoUrl = ds.Tables[0].Rows[i]["VideoUrl"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["VideoUrl"]); _SearchPrdctList.Add(_Prdouct); } SearchPrdctList.ProductList = _SearchPrdctList; } } return(SearchPrdctList); }
protected void Page_Load(object sender, EventArgs e) { string Json = ""; SearchProduct sp = new SearchProduct(); sp.ItemCount = 5; sp.ImgServer = "http://images.europe.creative.com"; sp.StoreUrl = ""; sp.SearchProductList = new List <SearchProductList>(); for (int i = 0; i < 5; i++) { SearchProductList p = new SearchProductList(); p.MasterProductID = Convert.ToInt32(i); p.ParentCategoryID = Convert.ToInt32(i); p.ProductName = "prodctName" + i.ToString(); string oneLine = ""; p.Text = string.IsNullOrEmpty(oneLine) ? "" : oneLine; p.Tag = "tag" + i.ToString().Trim(); sp.SearchProductList.Add(p); } Json = ToJson <SearchProduct>(sp); Response.Write(Json); }