Gridview的分页问题
来源:互联网 发布:地板防滑垫淘宝网 编辑:程序博客网 时间:2024/05/06 12:43
刚才我做实验时遇到了这样的一个问题:代码如下
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = db.creatconn();
con.Open();
SqlCommand cmd = new SqlCommand("SELECT [about], [link] FROM [ClassNews]", con);
SqlDataReader sdr = cmd.ExecuteReader();
this.GridView1.DataSource = sdr;
this.GridView1.DataBind();
}
GridView1的AllowPaging和 PageSize属性分别设为Yes 和5,但是执行时点击分页数却出错了,提示如下:
GridView“GridView1”激发了未处理的事件“PageIndexChanging”。
在网上查了大半天,终于成功了,现将代码修改如下:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = db.creatconn();
con.Open();
//SqlCommand cmd = new SqlCommand("SELECT [about], [link] FROM [ClassNews]", con);
//SqlDataReader sdr = cmd.ExecuteReader();
//this.GridView1.DataSource = sdr;
//this.GridView1.DataBind();
SqlDataAdapter sda = new SqlDataAdapter("SELECT [about], [link] FROM [ClassNews]", con);
DataSet ds = new DataSet();
sda.Fill(ds, "ClassNews");
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
GridView1就能正常地分页了。
- Gridview的分页问题
- 关于GridView的分页问题
- 关于GridView查询后分页的问题
- GridView的分页和按列头排序问题?
- gridview关于分页问题
- GridView分页问题
- GridView 分页问题
- gridview 分页问题
- GridView的分页
- GridView的分页功能
- GridView控件的分页
- gridview 简单的分页
- GridView的分页功能?
- GridView的分页
- GridView的分页
- GridView 的分页功能
- Gridview的分页功能
- Gridview控件的分页
- Win32汇编开发环境配置
- 关于FSB,CPU外频,我的电脑现状
- Javascript中最常用的55个经典技巧
- 集合类的学习--HashSet
- 只查找#的
- Gridview的分页问题
- 找DESKTOP 输入报名 找#
- 使用prototype.js的事件处理方法
- 网站性能监测服务--YMU简介
- asp.net
- 循环输入简洁写法&三选择语句嵌套
- 我的CSDN博客开通了,哈哈
- Integrating Smarty with the Zend Framework
- 集合类的学习--TreeSet