已经从表中取出了数据,代码如下: private void Form1_Load(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(@"server=.\SQLEXPRESS;user id=sa; password=sa; database=History;"))
{
SqlDataAdapter da = new SqlDataAdapter("select [ID],[UserName],[State],[Point],[Time] from OnOff ", con);
DataSet ds = new DataSet();
da.Fill(ds, "OnOff");
if (ds.Tables.Contains("OnOff"))
{
dataGridView1.DataSource = ds.Tables["OnOff"];
}
}
}我想要的功能是: 界面上4个按钮 ,"首页" "上一页" "下一页" "末页"。
请问该功能该如何实现,水平有限,希望最好能给出代码。
多谢!!
{
using (SqlConnection con = new SqlConnection(@"server=.\SQLEXPRESS;user id=sa; password=sa; database=History;"))
{
SqlDataAdapter da = new SqlDataAdapter("select [ID],[UserName],[State],[Point],[Time] from OnOff ", con);
DataSet ds = new DataSet();
da.Fill(ds, "OnOff");
if (ds.Tables.Contains("OnOff"))
{
dataGridView1.DataSource = ds.Tables["OnOff"];
}
}
}我想要的功能是: 界面上4个按钮 ,"首页" "上一页" "下一页" "末页"。
请问该功能该如何实现,水平有限,希望最好能给出代码。
多谢!!
http://topic.csdn.net/u/20100302/14/89daab72-2b33-4359-a14d-f559a17c9df5.html
using (SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=sa;database=Northwind"))
{
SqlDataAdapter sda = new SqlDataAdapter("select * from products", con);
DataSet ds = new DataSet();
int count, pageSize, currentPage;
int.TryParse(Request.Form["pageSize"], out pageSize);
pageSize = pageSize == 0 ? 10 : pageSize;
int.TryParse(Request.Form["count"], out count);
int.TryParse(Request.Form["pageNum"], out currentPage);
int tempCount = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
if (tempCount < currentPage)
{
currentPage = tempCount;
}
sda.Fill(ds, (currentPage - 1) * pageSize, pageSize, "products");
rp.DataSource = ds.Tables["products"].DefaultView;
rp.DataBind();
Response.Clear();
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
rp.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/Sandy945/archive/2009/05/22/4208998.aspx
Repeater 无刷新分页
http://blog.csdn.net/Sandy945/archive/2009/05/22/4208998.aspx
[SettingsPager Mode="ShowPager"]
[Summary AllPagesText="第{0}页 共{1}页 ({2} 条记录)" Text="第{0}页 共{1}页 ({2} 条记录)" /]
[/SettingsPager]