.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> MVC >> Post New QuestionBookmark and Share Subscribe to Forum

How to display 20 records each page in mvc4?

Posted By: ANIL     Posted Date: January 21, 2014    Points:5   Category :MVC
[CODE]@using PagedList
@using PagedList.Mvc
@model IEnumerable<Hoda.Models.demoproduct>

@{
ViewBag.Title = "Neww products";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<p>
<a href="~/Addnew/Create" class="btn btn-primary" style="text-align:center">Add New Car</a>

@using (Html.BeginForm("Index", "Addnew", FormMethod.Get))
{

<b>Search by</b>
@Html.RadioButton("searchBy", "TagNo", true)<text>Tagno</text>
@Html.RadioButton("searchBy", "StockNo", true)<text>StockNo</text>
<br />
@Html.TextBox("search")<input type="submit" value="Search" />
}

</p>
<table class="table table-striped" style="width:auto">


<tr>
<th>
@Html.DisplayNameFor(model => model.TagNo)
</th>
<th>
@Html.DisplayNameFor(model => model.StockNo)
</th>

<th>
@Html.DisplayNameFor(model => model.ProductName)
</th>
<th>
@Html.DisplayNameFor(model => model.Specifications)
</th>
<th>
@Html.DisplayNameFor(model => model.Quality_ValueAnalysis)
</th>
<th>
@Html.DisplayNameFor(model => model.Aboutus)
</th>

<th>
@Html.DisplayNameFor(model => model.Price)
</th>

</tr>
@if (Model.Count() == 0)
{
<tr>
<td colspan="4">No rows match for this search</td>
</tr>
}
else
{

foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.TagNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.StockNo)
</td>

<td>
@Html.DisplayFor(modelItem => item.ProductName)
</td>

<td>
@Html.Raw(item.Specifications)
</td>
<td>
@Html.Raw(item.Quality_ValueAnalysis)
</td>
<td>
@Html.Raw(item.Aboutus)
</td>

<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>


<td>
@Html.ActionLink("Edit", "Edit", new { id = item.TagNo })
@Html.ActionLink("Details", "Newcars", new { id = item.TagNo })

</td>


</tr>
}
}

</table>[/CODE]
[CODE]public ActionResult Index(string searchBy, string search)
{

if (searchBy == "TagNo")
{
return View(db.demoproducts.Where(x => x.TagNo == search || search == null).ToList());
}
else
{
return View(db.demoproducts.Where(x => x.StockNo.StartsWith(search) || search == null).ToList());
}
}[/CODE]
This is my actual code,
I want paging How can i do?

Responses

No response found. Be the first to respond this post
Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend