Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends ,

I am Trying to Get a result of product list in partial view ,

i want to add a information program to new product add system ,

i want show i.e when i type a word "T" in new product text-box i want to show how meany products is in product table that start a name from "T" ,

or i.e "TE" then its must to show products from name is "TE"
or any word or any name

so please help me to solve this ,

What I have tried:

jqUERY function
$(document).ready(function () {
			$("#Product_Name").keyup(function () {
				var pnm = $("#Product_Name").val().trim();
				alert(pnm);
				var Url = "/Product/SerchProd";
				$.post(Url, { pnm: pnm }, function (data) {
						$.get("/Product/SerchProdList", function (respnse) {
							$("#finalprd").html(respnse);
							$('.finalprd').SHOW();
							return false;
						});
	
				});

			});

		});



partial View()

@model IEnumerable




Product Name :



@foreach (var item in Model)
{


@Html.DisplayFor(modelItem => item.Product_Name)


}

Controller

public JsonResult SerchProd(string pnm)
   {


       TempData["pnm"] = pnm;
       TempData.Keep();
       return Json(pnm,JsonRequestBehavior.AllowGet);
   }

   public PartialViewResult SerchProdList()

   {
       string pnm = (string)TempData["pnm"];
       ViewBag.NameSortParm = String.IsNullOrEmpty(pnm) ? "Name_desc" : "";
       var prod = from p in dc.Product_master
                  select p;
       switch (pnm)
       {
           case "Name_desc":
               prod = prod.OrderByDescending(p => p.Product_Name);
               break;


       }

       return PartialView(prod.ToList());
   }
Posted
Comments
F-ES Sitecore 10-Apr-19 6:44am    
It's hard to say from what you've posted. Use the debugger to step through the process and see at what point it stops doing what you expect it to do. For example is the action even called? If not it might be you don't have the HttpPost attribute on the action. What does "prod.ToList()" ouput? Is it valid text\html? In your js you refer to both #finalprd and .finalprd, is there an element with that id and does it also have a finalprd class?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900