I have some basic c# code which connects to a database and prints out all rows returned i.e:
using (connection = new SqlConnection(ConfigurationManager.AppSettings["connString"]))
{
using (command = new SqlCommand("select * from table1", connection))
{
connection.Open();
using (reader = command.ExecuteReader())
{
while (reader.Read())
{
Div1.InnerHtml += reader["col1"].ToString() + "<br />";
}
}
}
}
How do I add pagination to this?
you can use Gridview control. it is more easier, rather than building your own pagination method.
for Paging, you can use OnPageIndexChanging event handler. Page Index Changing.