Actually what i am doing here is,
I want search functionality in MVC4 with database
In my database
Tagno-----int
StockNo----Varchar in my database
I want to search data from database using Tagno or StokeNo
VIEW:
@using (Html.BeginForm("Sss","Home",FormMethod.Get))
{
<p>
StockNo:@Html.TextBox("styleName")<br />
<input type="submit" value="Search StockNo" />
</p>
<p>
Tagno:@Html.TextBox("tagno")<br />
<input type="submit" value="Search Tagno" />
</p>
}
</p>
Controller:(Home)
public ActionResult Sss(string styleName,int? tagno)
{
var styles = from s in db.ProductsHondaofConyers select s;
if (!String.IsNullOrEmpty(styleName))
{
styles = styles.Where(c => c.StockNo.Contains(styleName));
}
else
{
styles = styles.Where(r => r.TagNo.Contains(tagno));
}
return View(styles);
}
Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator