|
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default3 : System.Web.UI.Page
{
#region Methods
private void ViewPage(int PageNo)
{
if (ViewState["_Items"] != null)
{
PagedDataSource objPds = new PagedDataSource();
DataTable dt = (DataTable)ViewState["_Items"];
objPds.DataSource = new DataView(dt);
objPds.AllowPaging = true;
objPds.PageSize = PagingControl1.NoRecordsPerPage;
objPds.CurrentPageIndex = PageNo - 1;
dlstItems.DataSource = objPds;
dlstItems.DataBind();
double d = Math.Ceiling(Convert.ToDouble(dt.Rows.Count) / PagingControl1.NoRecordsPerPage);
PagingControl1.PagesCount = Convert.ToInt32(d);
dlstItems.Visible = true;
PagingControl1.Visible = true;
lblResultMessage.Visible = false;
}
else
{
dlstItems.Visible = false;
lblResultMessage.Visible = true;
PagingControl1.Visible = false;
lblResultMessage.Text = "No Result";
}
}
private DataTable GetItems()
{
DataTable dt = new DataTable();
dt.Columns.Add("ItemId");
dt.Columns.Add("ItemName");
for (int i = 1; i <= 400; i++)
{
DataRow dr = dt.NewRow();
dr["ItemId"] = i.ToString();
dr["ItemName"] = "Item" + i;
dt.Rows.Add(dr);
}
return dt;
}
#endregion
#region Events
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//set control settings
PagingControl1.NoRecordsPerPage = 20;
PagingControl1.CurrentPageIndex = 1;
PagingControl1.NavigationLinkesCount = 12;
//Get Items data
ViewState["_Items"] = GetItems();
ViewPage(PagingControl1.CurrentPageIndex);
}
}
protected void PagingControl1_PageIndexClick(object sender, EventArgs e)
{
ViewPage(PagingControl1.CurrentPageIndex);
}
#endregion
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am experienced in web development with Microsoft technologies using ASP.NET Core ,C#, ASP.NET MVC, ASP.NET Web Api, ADO.NET ,LINQ, web services. I have a working experience with Model View Controller (MVC), and have been involved in maintaining versions of source code using TFS (Team Foundation Server) 2010. I have also developed web user controls, master pages, validation controls, CSS files using technologies like AJAX Toolkit, JQuery, JavaScript, Telerik UI controls, XML, HTML ,angular 1.4., angular 2 , typescript, SPA single page application.