我加上ASPNETPager控件后设置PageSize为10不起作用
我的页面代码如下:
<table align="center" border="1" cellpadding="0" cellspacing="0" style="height: 60px;">
<tr>
<th>编号</th>
<th>上级编号</th>
<th>排序编号</th>
<th>栏目名称</th>
<th>管理</th>
</tr>
<asp:Repeater ID="RPChannelList" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("ChannelID") %></td>
<td><%#Eval("TopID") %></td>
<td><%#Eval("OrderNum") %></td>
<td><%#Eval("ChannelName") %></td>
<td>
<a href="?cmd=del&ChannelID=<%#Eval("ChannelID") %>">删除</a>
<a href="Channel_Mod.Aspx?&ChannelID=<%#Eval("ChannelID") %>">修改</a>
</td>
</tr>
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:Repeater>
</table>
<webdiyer:AspNetPager ID="AspNetPager1" runat="server"
onpagechanged="AspNetPager1_PageChanged" FirstPageText="首页"
LastPageText="尾页" NextPageText="后页" PageIndexBoxType="TextBox"
PrevPageText="前页" ShowBoxThreshold="1" ShowPageIndexBox="Always"
SubmitButtonText="Go" TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到"
EnableTheming="True" NumericButtonCount="5" LayoutType="Table" AlwaysShow="True">
</webdiyer:AspNetPager>
.cs文件中代码如下:
void BindData()
{
DataTable coms = BLL.Channel.GetAll();
AspNetPager1.RecordCount = coms.Rows.Count;
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = coms.Rows;
RPChannelList.DataSource = pds;
RPChannelList.DataBind();
if (AspNetPager1.RecordCount < AspNetPager1.PageSize)
{
AspNetPager1.AlwaysShow = true;
}
希望大家帮帮忙,很急!
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BindData();
}
我的页面代码如下:
<table align="center" border="1" cellpadding="0" cellspacing="0" style="height: 60px;">
<tr>
<th>编号</th>
<th>上级编号</th>
<th>排序编号</th>
<th>栏目名称</th>
<th>管理</th>
</tr>
<asp:Repeater ID="RPChannelList" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("ChannelID") %></td>
<td><%#Eval("TopID") %></td>
<td><%#Eval("OrderNum") %></td>
<td><%#Eval("ChannelName") %></td>
<td>
<a href="?cmd=del&ChannelID=<%#Eval("ChannelID") %>">删除</a>
<a href="Channel_Mod.Aspx?&ChannelID=<%#Eval("ChannelID") %>">修改</a>
</td>
</tr>
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:Repeater>
</table>
<webdiyer:AspNetPager ID="AspNetPager1" runat="server"
onpagechanged="AspNetPager1_PageChanged" FirstPageText="首页"
LastPageText="尾页" NextPageText="后页" PageIndexBoxType="TextBox"
PrevPageText="前页" ShowBoxThreshold="1" ShowPageIndexBox="Always"
SubmitButtonText="Go" TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到"
EnableTheming="True" NumericButtonCount="5" LayoutType="Table" AlwaysShow="True">
</webdiyer:AspNetPager>
.cs文件中代码如下:
void BindData()
{
DataTable coms = BLL.Channel.GetAll();
AspNetPager1.RecordCount = coms.Rows.Count;
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = coms.Rows;
RPChannelList.DataSource = pds;
RPChannelList.DataBind();
if (AspNetPager1.RecordCount < AspNetPager1.PageSize)
{
AspNetPager1.AlwaysShow = true;
}
希望大家帮帮忙,很急!
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BindData();
}
解决方案 »
- discuz论坛的.NET版本怎么没了?
- 修改cookir的值无效,是要先将让其失效再重新添加吗?
- Datatable隨機排列
- 在线等~~ System.ArgumentException: 不支持关键字: “provider”。
- 求vs2005页面美工作的好的例子,总感觉自己的label,textbox,datagrid不好看。
- 为什么我装了msdn在SqlConnection上按F1还是找不到帮助
- 公司即时通讯的消息内容,储存在文本文件中,格式如下,请问如何将它们分离,并储存在数据库中.
- 高分求解关于DirectoryServices的问题
- UpdatePanel 如何保存VIEWSTATE?或者类似的保存方法,在异步更新后能读取
- DataGrid中绑定Button显示的问题
- 网站N多个问题!
- 请教一个返回值的问题。感激!!
AlwaysShow="True" OnPageChanged="AspNetPager1_PageChanged"AspNetPager1.RecordCount = list.Count;
//分页查询数据
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BindData();
}