日期:2014-05-18  浏览次数:20486 次

GridView 分页
GridView启用分页之后只在GridView中有 1 2 3 4.....
我想让他分页变成 ”首页 上一页 1 2 3 4..... 下一页 末页“这种格式应该怎么做?????

------解决方案--------------------
看看下面我写的代码:
<asp:GridView DataSourceID="SDS1" Width="600px" ID="GridView1" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PagerSettings-Mode="NextPreviousFirstLast" PagerSettings-NextPageText="下一页" PagerSettings-PreviousPageText="上一页" PagerSettings-FirstPageText="首 页" PagerSettings-LastPageText="尾 页" PageSize="20" Runat="server">
<HeaderStyle BackColor="Orange" ForeColor="White"></HeaderStyle>
<Columns>
<asp:CommandField ItemStyle-ForeColor="Gray" ShowSelectButton="true"/>
<asp:BoundField ItemStyle-ForeColor="#666666" DataField="hostId" HeaderText="电脑编号" SortExpression="hostId"></asp:BoundField>
<asp:BoundField ItemStyle-ForeColor="#666666" DataField="IP" HeaderText="IP" SortExpression="IP"></asp:BoundField>
<asp:BoundField ItemStyle-ForeColor="#666666" DataField="deptName" HeaderText="部门名称" SortExpression="deptName"></asp:BoundField>
<asp:BoundField ItemStyle-ForeColor="#666666" DataField="duty" HeaderText="职务" SortExpression="duty"></asp:BoundField>
<asp:BoundField ItemStyle-ForeColor="#666666" DataField="empName" HeaderText="使用人" SortExpression="empName"></asp:BoundField>
<asp:BoundField ItemStyle-ForeColor="#666666" DataField="itsPassCN" HeaderText="审核否" SortExpression="itsPassCN"></asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="Silver" ForeColor="White" />
</asp:GridView>
------解决方案--------------------
探讨
看看下面我写的代码:
<asp:GridView DataSourceID="SDS1" Width="600px" ID="GridView1" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PagerSettings-Mode="NextPreviousFirstLast" PagerSettings-NextPageText="下一页" PagerSettings-PreviousPageText="上一页" PagerSettings-FirstPageText="首 页" PagerSettings-LastPageText="尾 页" PageSize="20" Runat="server">
<HeaderStyle BackColo…

------解决方案--------------------
我给你一个,我自己写的
 <FooterStyle BackColor ="#CCCCC" ForeColor ="Black" />
<RowStyle BackColor ="#EEEEE" ForeColor ="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold ="true" ForeColor ="White" />
<PagerStyle BackColor="#99999" ForeColor ="Black" HorizontalAlign ="Center" />
<HeaderStyle BackColor="#000084" Font-Bold ="true" ForeColor ="White" />
<AlternatingRowStyle BackColor ="Gainsboro" />
<PagerSettings FirstPageText ="首页" LastPageText ="尾页" NextPageText ="下一页" PreviousPageText ="上一页" Mode ="NextPreviousFirstLast" />
------解决方案--------------------
这个需要自己自定义分页了!不过也简单!
如下代码:
C# code

 #region GridView1页码跳转
        protected void link_next_Click(object sender, EventArgs e)
        {
            if