AspNetPager4.33 分页问题 DataGrid分页时用AspNetPager ,显示数据不全。为什么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下是我的代码,大家帮忙看看<webdiyer:aspnetpager id="AspNetPager1" runat="server" Width="100%" HorizontalAlign="center" ShowInputBox="always" SubmitButtonStyle="border:1px solid #000066;height:20px;width:30px" InputBoxStyle="border:1px #0000FF solid;text- align:center" CssClass="mypager" TextBeforeInputBox="转到第" TextAfterInputBox="页" AlwaysShow="True" NumericButtonCount="20" FirstPageText="首页" NextPageText="下一页" PrevPageText="上一页" LastPageText="尾页" SubmitButtonText="Go"></webdiyer:aspnetpager>private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if(!Page.IsPostBack) { BindData(); } }protected void BindData() { string connStr = "server=.;database=softwaremanage;uid=sa;pwd=sa";//设定数据库连接字符串 SqlConnection conn = new SqlConnection(connStr);//连接数据库 conn.Open();//打开数据库 string sql = "select * from SoftwareInfo"; SqlCommand comm = new SqlCommand(sql, conn); SqlDataAdapter da = new SqlDataAdapter(comm); DataSet ds = new DataSet(); da.Fill(ds, "SoftwareInfo"); PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables[0].DefaultView;//设置分页的数据源 pds.AllowPaging = true;//设置允许分页 AspNetPager1.RecordCount = pds.Count;//AspNetPager1.RecordCount = ds.Tables[0].DefaultView.Count;等价//获取数据的条数 pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;//设置当前页的索引 pds.PageSize = AspNetPager1.PageSize;//设置每页显示的页数 this.DataGrid.DataSource = pds; this.DataGrid.DataBind();//绑定数据 }public void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e) { AspNetPager1.CurrentPageIndex = e.NewPageIndex; BindData(); } SqlCommand comm = new SqlCommand(sql, conn); SqlDataAdapter da = new SqlDataAdapter(comm);换成SqlDataAdapter da = new SqlDataAdapter(sql, conn); http://www.cnblogs.com/jembai/archive/2008/09/23/1296899.html 你说的数据不全是什么不全,是不是应该是10条,确显示了8条?看看你的dataGrid 里和AspNetPager1的PageSize属性. http://www.cnblogs.com/yangtu86/archive/2006/06/27/436897.html //注意下面这句,只填充当前页要显示的数据,不能把所有数据全填充到DataSet中,否则无法实现分页 da.Fill(ds,pager.PageSize*(pager.CurrentPageIndex-1),pager.PageSize,"newtable"); 在WebUserControl下 IsValid失效?? 哪位大虾介绍下,现在上传图片是放在目录里,还是把路径存入数据库! RadGrid控件自定义表头 一个SQL问题 关于水晶报表的问题,大家帮忙? .net2005母板页可以嵌套么 谁能解决考试系统交卷时的并发问题,高分相送,MONEY也可以! 高手请解答在repeater中按钮时常丢失事件的问题! 数据库连接问题 MVC 关于dropdownlist onchange无法触发 Infragistics的WebWeekView数据绑定问题(vb.net) 页面返回值:如何得到其他网站页面的返回值?
SubmitButtonStyle="border:1px solid #000066;height:20px;width:30px" InputBoxStyle="border:1px #0000FF solid;text- align:center"
CssClass="mypager" TextBeforeInputBox="转到第" TextAfterInputBox="页" AlwaysShow="True" NumericButtonCount="20" FirstPageText="首页"
NextPageText="下一页" PrevPageText="上一页" LastPageText="尾页" SubmitButtonText="Go"></webdiyer:aspnetpager>private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
BindData();
}
}protected void BindData()
{
string connStr = "server=.;database=softwaremanage;uid=sa;pwd=sa";//设定数据库连接字符串
SqlConnection conn = new SqlConnection(connStr);//连接数据库
conn.Open();//打开数据库
string sql = "select * from SoftwareInfo";
SqlCommand comm = new SqlCommand(sql, conn);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
da.Fill(ds, "SoftwareInfo");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;//设置分页的数据源
pds.AllowPaging = true;//设置允许分页
AspNetPager1.RecordCount = pds.Count;//AspNetPager1.RecordCount = ds.Tables[0].DefaultView.Count;等价//获取数据的条数
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;//设置当前页的索引
pds.PageSize = AspNetPager1.PageSize;//设置每页显示的页数
this.DataGrid.DataSource = pds;
this.DataGrid.DataBind();//绑定数据
}public void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindData();
}
SqlDataAdapter da = new SqlDataAdapter(comm);换成
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
看看你的dataGrid 里和AspNetPager1的PageSize属性.
da.Fill(ds,pager.PageSize*(pager.CurrentPageIndex-1),pager.PageSize,"newtable");