using System; using System.Data; using System.Web.UI.WebControls; using UG.Common; public partial class FAQ : System.Web.UI.Page { PagedDataSource pg; public int PageIndex { set { ViewState["PageIndex"] = value; } get { return ((int)ViewState["PageIndex"]); } } public int PageSize { get { return ((int)ViewState["PageSize"]); } set { ViewState["PageSize"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.PageIndex = 0; BindList(); } } private void BindList() { UG.Common.FAQ objFAQ = new UG.Common.FAQ(); try { DataTable dt = objFAQ.GetFAQ(); pg = new PagedDataSource(); if (dt.Rows.Count > 20) { trPaging.Visible = true; } else { trPaging.Visible = false; } pg.DataSource = dt.DefaultView; pg.AllowPaging = true; pg.PageSize = 20; try { pg.CurrentPageIndex = this.PageIndex; } catch { pg.CurrentPageIndex = 0; } lnkNext.Enabled = !pg.IsLastPage; lnkPrev.Enabled = !pg.IsFirstPage; if (dt.Rows.Count <= 0) { lnkPrev.Enabled = false; lnkNext.Enabled = false; } lblPage.Text = "Page : " + (pg.CurrentPageIndex + 1).ToString(); dlFAQW.DataSource = pg; dlFAQW.DataBind(); } catch (Exception ex) { Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, "Business Exception Policy"); lblError.Text = "Some error occured."; //throw; } } protected void lnkPrev_Click(object sender, EventArgs e) { try { this.PageIndex -= 1; BindList(); } catch(Exception ex) { Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, "Business Exception Policy"); lblError.Text = "Some error occured."; //throw; } } protected void lnkNext_Click(object sender, EventArgs e) { try { this.PageIndex += 1; BindList(); } catch(Exception ex) { Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, "Business Exception Policy"); lblError.Text = "Some error occured."; //throw; } } }