protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
con.Open();
ds = new DataSet();
string sql = "SELECT * FROM Internet";
da = new SqlDataAdapter(sql, con);
da.Fill(ds, "Internet");
Maxrows = ds.Tables["Internet"].Rows.Count;
Label2.Text = inc.ToString();
Label3.Text = Maxrows.ToString();
Records();
con.Close();
}
private void Records()
{
drow = ds.Tables["Internet"].Rows[inc];
Label1.Text = drow.ItemArray.GetValue(1).ToString();
inc++;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (inc <= Maxrows )
{
Records();
Label2.Text = inc.ToString();
}
}
}
I have this above code and I am trying to display a number of records from a database on a web application. when I first load the page it load the first record. I click the next button and displays the second button. I have 3 records but the 3rd record never displays why? please can anyone help?