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; using System.Windows.Forms; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { int count; void load() { if (ViewState["dsrownum"] == null) { ViewState["dsrownum"] = 0; } SqlConnection connect = new SqlConnection(); DataSet ds = new DataSet(); connect.ConnectionString = ConnectionStr.ConnectionString; SqlDataAdapter da = new SqlDataAdapter("select * from tbl_news", connect); da.Fill(ds, "tbl_news"); count = ds.Tables["tbl_news"].Rows.Count; lbl_Onvan.Text = ds.Tables["tbl_news"].Rows[(int)ViewState["dsrownum"]]["title"].ToString(); lbl_Matn.Text = ds.Tables["tbl_news"].Rows[(int)ViewState["dsrownum"]]["news"].ToString(); lbl_Nevisande.Text = ds.Tables["tbl_news"].Rows[(int)ViewState["dsrownum"]]["writer"].ToString(); if ((int)ViewState["dsrownum"] == 0) { LinkButton_pre.Enabled = false; } else { LinkButton_pre.Enabled = true; ; } if ((int)ViewState["dsrownum"] + 1 == count) { LinkButton_next.Enabled = false; } else { LinkButton_next.Enabled = true; ; } } protected void Page_Load(object sender, EventArgs e) { load(); } protected void LinkButton2_Click(object sender, EventArgs e) { ViewState["dsrownum"] = (int)ViewState["dsrownum"] + 1; load(); } protected void LinkButton_pre_Click(object sender, EventArgs e) { ViewState["dsrownum"] = (int)ViewState["dsrownum"] - 1; load(); } }