Line 31: dset = new DataSet(); Line 32: adsource = new PagedDataSource(); Line 33: dadapter.Fill(dset); Line 34: adsource.DataSource = dset.Tables[0].DefaultView; Line 35: adsource.PageSize = 3;
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; public partial class Default2 : System.Web.UI.Page { SqlDataAdapter dadapter; DataSet dset; PagedDataSource adsource; string connstring = "server=.......;user id=sa;password=.....;database=IMADB"; int pos; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ViewState["vs"] = 0; } pos = (int)this.ViewState["vs"]; databind(); } private void databind() { dadapter = new SqlDataAdapter("select * from IMADB_tbluser", connstring); dset = new DataSet(); adsource = new PagedDataSource(); dadapter.Fill(dset); adsource.DataSource = dset.Tables[0].DefaultView; adsource.PageSize = 3; adsource.AllowPaging = true; adsource.CurrentPageIndex = pos; btnfirst.Enabled = !adsource.IsFirstPage; btnprevious.Enabled = !adsource.IsFirstPage; btnlast.Enabled = !adsource.IsLastPage; btnnext.Enabled = !adsource.IsLastPage; GridView1.DataSource = adsource; GridView1.DataBind(); } protected void btnfirst_Click(object sender, EventArgs e) { pos = 0; databind(); } protected void btnprevious_Click(object sender, EventArgs e) { pos = (int)this.ViewState["vs"]; pos += 1; this.ViewState["vs"] = pos; databind(); } protected void btnnext_Click(object sender, EventArgs e) { pos = (int)this.ViewState["vs"]; pos += 1; this.ViewState["vs"] = pos; databind(); } protected void btnlast_Click(object sender, EventArgs e) { pos = adsource.PageCount-1; databind(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)