gridview 中的分页
我的 gridView:
<asp:GridView ID="gridView1" runat="server" CellPadding="4" AllowPaging="true" PageSize="5" emptydatatext="No data available."
CssClass="datagrid"
ForeColor="#333333" GridLines="None"
onrowcreated="gridView1_RowCreated"
onpageindexchanging="gridView1_PageIndexChanging">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
和我的代码隐藏:
protected void gridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView1.PageIndex = e.NewPageIndex;
BindDataGrid();
}
protected void BindDataGrid()
{
DataSet ds = new DataSet();
ds = dbM.GetInfo(name, mobilePhone, info1); //get info to BD and save in "ds"
gridView1.DataSource = ds;
gridView1.DataBind();
}
并且“分页”不起作用。它显示前 5 行,但不显示分页数
这是什么问题???
请帮忙
谢谢
My gridView:
<asp:GridView ID="gridView1" runat="server" CellPadding="4" AllowPaging="true" PageSize="5" emptydatatext="No data available."
CssClass="datagrid"
ForeColor="#333333" GridLines="None"
onrowcreated="gridView1_RowCreated"
onpageindexchanging="gridView1_PageIndexChanging">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
And my codebehind:
protected void gridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView1.PageIndex = e.NewPageIndex;
BindDataGrid();
}
protected void BindDataGrid()
{
DataSet ds = new DataSet();
ds = dbM.GetInfo(name, mobilePhone, info1); //get info to BD and save in "ds"
gridView1.DataSource = ds;
gridView1.DataBind();
}
and the "Paging" does not work. It shows the first 5 rows, but does not show the number of paging
What´s wrong???
Please help
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试在
GridView
标记中添加一些寻呼机设置:如果有效,您可以将其更改为您想要的外观。有许多选择,包括
NumericFirstLast)
Try adding some pager settings in the
GridView
tag:If that works, you can change it to your desired appearance. There are many choices, including
NumericFirstLast)
添加 PagerSettings-GridView-Markup 的属性并将其设置为
True
:编辑:但默认情况下应该为
true
,所以我不确定这是否会改变什么Add the PagerSettings-Property to the GridView-Markup and set it to
True
:Edit: but it should be
true
by default, so i'm not sure if this will change anything