How to creating Paging in asp.net mvc3 project?
Hi all
Iam working with Asp.net mvc3 Project.Here in my list view I want to creating paging
I tired alot i didn't get any solution please provide solution
my model class is
SelectSiteModel.cs
public class SelectSiteModel
{
//[Required]
//public string SiteID { get; set; }
[Required]
public string SiteName { get; set; }
[Required]
public string SiteAddress { get; set; }
[Required]
public string WorkOrderNo { get; set; }
public DataSet GetAllSiteDetails()
{
SqlConnection cn = new SqlConnection(@"Data Source=USHODAYA-PC1;Initial Catalog=VendorManagement;Integrated Security=True");
SqlCommand cmd = new SqlCommand("Select * From Site", cn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
return ds;
}
}
and my Cotroller code is
public ActionResult Index(SelectSiteModel selectSiteModel)
{
DataSet ds = selectSiteModel.GetAllSiteDetails();
ViewBag.SiteList = ds.Tables[0];
return View();
}
Index.cshtml is
<table>
<tr>
</tr>
<tr> <td></td>
<td style="background-color: #800080; color: #FFFFFF; font-family: 'Times New Roman', Times, serif;
font-size: large; border-style: inset; border-width: thin">
SiteID
</td>
<td style="background-color: #800080; color: #FFFFFF; font-family: 'Times New Roman', Times, serif;
font-size: large; border-style: inset; border-width: thin">
SiteName
</td>
<td style="background-color: #800080; color: #FFFFFF; font-family: 'Times New Roman', Times, serif;
font-size: large; border-style: inset; border-width: thin">
Site Address
</td>
<td style="background-color: #800080; color: #FFFFFF; font-family: 'Times New Roman', Times, serif;
font-size: large; border-style: inset; border-width: thin">
Site WOrkOrderNo
</td>
</tr>
@foreach (System.Data.DataRow dr in ViewBag.SiteList.Rows) {
<tr>
<td>
@Html.ActionLink("Edit", "UpdateSite", new { id = dr["SiteId"].ToString() })
@* @Html.ActionLink("Delete", "Delete", new { id = dr["SiteId"].ToString()})*@
</td>
<td>
@dr["SiteId"].ToString()
</td>
<td>
@dr["SiteName"].ToString()
</td>
<td>
@dr["SiteAddress"].ToString()
</td>
<td>
@dr["WorkOrderNo"].ToString()
</td>
</tr>
}
</table>
Please give solution for this
Regards
NagaRaju