我现在用的是GridView的自动分页(页码)
显示为
...1 2 3 4 5...
这种形式
现在我想把...改为 下十页
再加上一页,下一页。
不知道才能!
显示为
...1 2 3 4 5...
这种形式
现在我想把...改为 下十页
再加上一页,下一页。
不知道才能!
解决方案 »
- GridView“GridView1”激发了未处理的事件“RowDeleting”。
- 在谷歌地图上根据具体地址获取经纬度信息
- 网站计数器的问题
- 正则表达式提取网页中图片的路径
- dataset如何筛选数据
- 问一个关于showModelessDialog()的问题
- 把datagrid中的5萬多條記錄導出到一個excel表時出錯.請問要怎樣解決呀.
- csc /r:"C:\Office XP PIAs\Microsoft.Office.Interop.Word.dll" example1.cs 后出现错误fatal error csc 2008:未指定输入。
- 给自定义的gridview添加双击事件
- 为什么文件下载文件名是乱吗?代码如下
- 高分诚心请教,aspnet_compiler中的参数问题
- 用到母版页时在内容页里怎么用JS找到控件
也可以用aspnetpager控件,最新版本发布没几天.很不错的分页控件,免费开源的
<asp:GridView ID="GridView2" runat="server" Height="138px" Style="left: 55px; position: absolute;
top: 240px" Width="603px" AutoGenerateColumns="False" OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView2_RowDataBound" AllowPaging="True" PageSize="2" CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" Text="全选" OnCheckedChanged="CheckBox2_CheckedChanged" AutoPostBack="true" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="Chkitem" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Id") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="authorName" HeaderText="作者" />
<asp:BoundField DataField="City" HeaderText="城市" />
</Columns>
<PagerSettings Visible="False" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:Panel ID="Panel1" runat="server" BackColor="#FF80FF" Height="34px" Style="left: 55px;
position: absolute; top: 379px" Width="609px">
<asp:Button ID="cmdFirst" runat="server" CommandArgument="first" CommandName="page"
OnClick="cmdFirst_Click" Style="left: 10px; position: absolute; top: 4px" Text="首页"
Width="57px" Height="25px" />
<asp:Button ID="cmdPrevious" runat="server" CommandArgument="previous" CommandName="page"
OnClick="cmdPrevious_Click" Style="left: 67px; position: absolute; top: 5px"
Text="上一页" />
<asp:Button ID="cmdNext" runat="server" CommandArgument="next" CommandName="page"
OnClick="cmdNext_Click" Style="left: 127px; position: absolute; top: 5px" Text="下一页" />
<asp:Button ID="cmdLast" runat="server" CommandArgument="last" CommandName="page"
OnClick="cmdLast_Click" Style="left: 187px; position: absolute; top: 5px" Text="尾页"
Width="58px" />
<asp:Label ID="Label1" runat="server" Style="left: 251px; position: absolute; top: 8px"
Text="Label" Width="61px"></asp:Label>
<asp:Button ID="cmdTrans" runat="server" Style="left: 466px; position: absolute; top: 5px"
Text="go" OnClick="cmdTrans_Click" />
<asp:Label ID="Label2" runat="server" Style="left: 404px; position: absolute; top: 8px"
Text="第" Width="22px"></asp:Label>
<asp:TextBox ID="txtNumber" runat="server" onkeypress="return event.keyCode>=48&&event.keyCode<=57||event.keyCode==46" onpaste="return !clipboardData.getData('text').match(/\D/)" style="ime-mode:Disabled; left: 425px; position: absolute; top: 5px;" ondragenter="return false" Width="29px"></asp:TextBox>
<asp:Label ID="Label4" runat="server" Style="left: 316px; position: absolute; top: 8px"
Text="Label"></asp:Label>
<asp:Label ID="Label3" runat="server" Style="left: 349px; position: absolute; top: 8px"
Text="Label"></asp:Label>
</asp:Panel>
</div>
{
string sqlStr = "select * from authors order by id";
db myDb = new db();
GridView2.DataSource = myDb.dt(sqlStr);
GridView2.AllowPaging = true;
GridView2.PageSize = 2;
GridView2.DataBind();
Label1.Text = "共" + GridView2.PageCount + "页" +" / ";
Label4.Text =Convert.ToString(GridView2.PageIndex + 1);
Label3.Text = " 页";
if (GridView2.PageIndex == 0)
{
cmdFirst.Enabled = false;
cmdPrevious.Enabled = false;
}
else
{
cmdFirst.Enabled = true;
cmdPrevious.Enabled = true;
} if (GridView2.PageIndex == GridView2.PageCount - 1)
{
cmdNext.Enabled = false;
cmdLast.Enabled = false;
}
else
{
cmdNext.Enabled = true;
cmdLast.Enabled = true;
}
}
{
GridView2.PageIndex = 0;
bind2();
}
protected void cmdPrevious_Click(object sender, EventArgs e)
{
GridView2.PageIndex = GridView2.PageIndex - 1;
bind2();
} protected void cmdNext_Click(object sender, EventArgs e)
{
GridView2.PageIndex = GridView2.PageIndex + 1;
bind2();
}
protected void cmdLast_Click(object sender, EventArgs e)
{
GridView2.PageIndex = GridView2.PageCount - 1;
bind2();
}