C# 存储过程分页
来源:互联网 发布:淘宝旺旺如何设置 编辑:程序博客网 时间:2024/04/30 15:28
create procedure proc_GetBy_Rownumber --SQL 2005 及以上 @pageIndex int, @pageSize int --userID,userName,userAge 表字段as begin set nocount on; select * from (select userID,userName,userAge,Row_number() over(order by userid asc) as IDNum from dbo.ProcUserInfo) as Info where IDNum>@pageSize*@pageIndex and IDNum<@pageSize*(@pageIndex+1) set nocount off; end
private static int pageCount;
public int pageIndex { get { if (ViewState["pageIndex"] == null) { ViewState["pageIndex"] = 0; } return Convert.ToInt32(ViewState["pageIndex"]); } set { ViewState["pageIndex"] = value; } } public void Bind() { int total = 110002; int pagesize = 100; pageCount = total / pagesize == 0 ? total / pagesize : (total / pagesize) + 1; SqlCommand cmd = new SqlCommand("proc_GetBy_Rownumber", conn); cmd.CommandType = CommandType.StoredProcedure; SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@pageIndex", SqlDbType.Int); param[0].Value = pageIndex; param[1] = new SqlParameter("@pageSize", SqlDbType.Int); param[1].Value = pagesize; cmd.Parameters.AddRange(param); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); if (pageIndex==0) { this.Button5.Enabled = false; this.Button6.Enabled = false; this.Button7.Enabled = true; this.Button8.Enabled = true; } else if(pageIndex!=0&& pageIndex != pageCount - 1) { this.Button5.Enabled = true; this.Button6.Enabled = true; this.Button7.Enabled = true; this.Button8.Enabled = true; } else { this.Button5.Enabled = true; this.Button6.Enabled = true; this.Button7.Enabled = false; this.Button8.Enabled = false; } this.GridView1.DataSource = dt; this.GridView1.DataBind(); this.Label1.Text = "总共:" + total.ToString() + "条/每页100条/共" + pageCount + "页/当前第" + (pageIndex + 1) + "页"; }
/// <summary> /// 首页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button5_Click(object sender, EventArgs e) { if (pageIndex != 0) { pageIndex = 0; } Bind(); } /// <summary> /// 上一页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button6_Click(object sender, EventArgs e) { if (pageIndex != 0) { pageIndex--;
} Bind(); } /// <summary> /// 下一页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button7_Click(object sender, EventArgs e) { if (pageIndex != pageCount) { pageIndex++;
} Bind(); } /// <summary> /// 末页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button8_Click(object sender, EventArgs e) { if (pageIndex != pageCount) { pageIndex = pageCount - 1;
} Bind(); }
- C# 存储过程 分页
- C# 存储过程分页
- C#分页存储过程
- C# + SQL 存储过程分页
- C#中使用存储过程,C#分页存储过程
- c# oracle 存储过程分页查询
- C#调用Oracle存储过程分页
- C#调用Oracle存储过程分页
- C#高效分页代码(不用存储过程)
- C#调用Oracle存储过程分页
- C#调用SQL Server分页存储过程
- C#方法 Repeater、webdiyer:AspNetPager分页、存储过程分页
- C# DataGridView分页功能(SQL分页存储过程实现)
- c#学习之-c#通过sql存储过程实现分页
- 通用分页SQL(不要存储过程)(C#实现)(
- 存储过程分页 及其排序 完整代码 .net C#
- 针对分页存储过程调用的C#类
- C# GridView DataList存储过程分页(效率高)
- SC44B0的内存地址解析
- sap学习天地
- 12306网购火车票技巧春节订票技巧
- 使用jQuery_validate插件时遇到的问题(一)
- AS3.0杂记——Vector与Array的比美
- C# 存储过程分页
- 关于报错 'Could not instantiate class named NSLayoutConstraint
- C#中容器控件GroupBox、Panel、TabControl的应用
- 说说JSON和JSONP,也许你会豁然开朗,含jQuery用例
- OpenCL开发案例学习
- buntu和XP互相远程连接
- hibernate中Query的用法
- ubuntu下配置VIM做PHP的IDE开发环境
- 智能指针 shared_ptr