Search functionality using mvc4? based on condition

Posted by Mandlaa under ASP.NET MVC on 10/7/2013 | Points: 10 | Views : 1605 | Status : [Member] | Replies : 1
User can search by id When user click search , display only matchaing details.

This is my code for searching

public ActionResult Searchproduct(string search)
{
if (search == "StockNo")
{
return View(db.ProductsHondaofConyers.Where(x => x.StockNo == search).ToList());
}
else
{
return View("Searchproduct");
}
}

VIEW:

@using (Html.BeginForm("Searchproduct","Hondaofconyers",FormMethod.Get))
{
@Html.RadioButton("id","StockNo",true)<text>StockNo</text>
@Html.TextBox("search")<input type="submit" value="search"/>
}
</p>

I am getting an error like this

ERROR:

An exception of type 'System.NullReferenceException' occurred in App_Web_mrlgxop0.dll but was not handled in user code

Additional information: Object reference not set to an instance of an object.




Responses

Posted by: Bandi on: 10/7/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer
http://stackoverflow.com/questions/18429026/applying-searching-in-asp-net-mvc4
http://www.youtube.com/watch?v=Uca8AmwzM4E
http://www.mindstick.com/Articles/74883949-5c3c-4509-b1ff-7a4be371f993/?Search%20Functionality%20in%20ASP%20NET%20MVC%204

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response