Paging Advantage of Datalist Control in asp.net with c#&visual basic

Unknown | 5:51 AM |

HTML Coding :


















Server Side Coding: c#

SqlConnection scn = new SqlConnection("Data Source=.;Initial Catalog=iptv_database;Integrated Security=True");
int Start;
protected void Page_Load(object sender, EventArgs e)
{

if (!Page.IsPostBack)
{
ViewState["Start"] = 0;
BindData();
}
}
void BindData()
{

SqlDataAdapter da = new SqlDataAdapter("select * from addprogram", scn);
DataSet ds= new DataSet();
Start = (int)ViewState["Start"];
ViewState["Size"] = 2;
da.Fill(ds,Start,(int)ViewState["Size"], "addprogram");
DataList1.DataSource = ds;
DataList1.DataBind();


}
protected void lnkPrevious_Click(object sender, EventArgs e)
{
Start = (int)ViewState["Start"] - (int)ViewState["Size"];
ViewState["Start"] = Start;
if (Start <= 0)
{
ViewState["Start"] = 0; 

BindData();
}
protected void lnkNext_Click(object sender, EventArgs e)
{
int count = DataList1.Items.Count;
Start = (int)ViewState["Start"] + (int)ViewState["Size"];
ViewState["Start"] = Start;
if (count <(int)ViewState["Size"])
{
ViewState["Start"] = (int)ViewState["Start"] + (int)ViewState["Size"];
Start = (int)ViewState["Start"];}
}

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....