分页显示的问题

chenyl0925 2003-08-20 11:09:57
下列代码实现分页显示怎么不成功?
string conString = "server = (local);database = pratice;user id = sa; pwd = ";
SqlConnection myConnection = new SqlConnection(conString);
SqlDataAdapter myCommand = new SqlDataAdapter(sqlString,myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds,"unformatdata");
this.DataGrid1.PageSize = 5;
//this.DataGrid1.PageSize = System.Convert.ToInt16(this.DropDownList1.SelectedItem.Value);
//this.DropDownList1.Items.FindByValue(this.DataGrid1.PageSize.ToString()).Selected = true;
if (ds.Tables["unformatdata"].Rows.Count == 0) //没有找到记录
{.....}
else{
DataGrid1.DataSource = ds.Tables["unformatdata"];
DataGrid1.DataBind();
this.Lab_Count_A.Text = "第"+System.Convert.ToString(DataGrid1.CurrentPageIndex+1)+"页/共"+this.DataGrid1.PageCount.ToString()+"页";
this.Lab_Count_B.Text = "第"+System.Convert.ToString(DataGrid1.CurrentPageIndex+1)+"页/共"+this.DataGrid1.PageCount.ToString()+"页";
}
开始用的注释的语句,试验不行,后来改用其上面一句说明DataGrid1.PageSize 值
为什么明明DataGrid1记录数超过5还是不分页。谢谢!
...全文
31 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chcpu 2003-08-22
  • 打赏
  • 举报
回复
{.....}
else{
try{
DataGrid1.CurrentPageIndex=int.Parse((this.DropDownList1.SelectedItem.Value))-1;
}
catch
{
DataGrid1.CurrentPageIndex=0;
}

DataGrid1.DataSource = ds.Tables["unformatdata"];
DataGrid1.DataBind();
this.Lab_Count_A.Text = "第"+System.Convert.ToString(DataGrid1.CurrentPageIndex+1)+"页/共"+this.DataGrid1.PageCount.ToString()+"页";
this.Lab_Count_B.Text = "第"+System.Convert.ToString(DataGrid1.CurrentPageIndex+1)+"页/共"+this.DataGrid1.PageCount.ToString()+"页";
}
zjw19 2003-08-20
  • 打赏
  • 举报
回复
up
wacle 2003-08-20
  • 打赏
  • 举报
回复
需要自己写代码来控制的
dgrd.currentpageindex+=1;
bindgrid();//需要重新邦定
acewang 2003-08-20
  • 打赏
  • 举报
回复
这么乱,眼晕
chenyl0925 2003-08-20
  • 打赏
  • 举报
回复
to wacle([Smile!]), 请问自己写代码控制应该在哪儿写?
程序的大概意思是:
查询结果,如果有结果的话则分页显示。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧