本文介绍了使用c#中的下一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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(); // displays the number of rows
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(); // outputs the row number which is being displayed
}
}
}
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?
推荐答案
这篇关于使用c#中的下一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!