我想在分页中实现这种样式,并且数字像CSDN分页那样,点了之后变成红色。:
1 2 3 4 5 6 7 8 9 10 ... (共 12 页 当前第1页)
我现在用了这段代码
protected void GridView1_DataBound(object sender, EventArgs e)
{
GridViewRow gvRow = this.GridView1.BottomPagerRow;
Label pagerLBL = new Label();
pagerLBL.Text = " (共 " + this.GridView1.PageCount.ToString() + " 页 " + "当前第"+ (this.GridView1.PageIndex+1).ToString() +"页)";
gvRow.Cells[0].Controls.Add(pagerLBL);
}
只能实行这种样式:
1 2 3 4 5 6 7 8 9 10 ...
(共 12 页 当前第1页)谢谢各位!!!
1 2 3 4 5 6 7 8 9 10 ... (共 12 页 当前第1页)
我现在用了这段代码
protected void GridView1_DataBound(object sender, EventArgs e)
{
GridViewRow gvRow = this.GridView1.BottomPagerRow;
Label pagerLBL = new Label();
pagerLBL.Text = " (共 " + this.GridView1.PageCount.ToString() + " 页 " + "当前第"+ (this.GridView1.PageIndex+1).ToString() +"页)";
gvRow.Cells[0].Controls.Add(pagerLBL);
}
只能实行这种样式:
1 2 3 4 5 6 7 8 9 10 ...
(共 12 页 当前第1页)谢谢各位!!!
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (GridView1.AllowPaging && e.Row.RowType == DataControlRowType.Pager)
{
TableRow row = ((Table)e.Row.Cells[0].Controls[0]).Rows[0];
if (row.Cells.Count == 0)
return; TableCell cell = row.Cells[0]; Label pagerLBL = new Label();
pagerLBL.Text = " (共 " + this.GridView1.PageCount.ToString() + " 页 " + "当前第" + (this.GridView1.PageIndex + 1).ToString() + "页)"; cell.Controls.Add(pagerLBL);
}
}
改成
row.Controls.Add(pagerLBL);试试
if (row.Cells.Count == 0)
return; TableCell cell = row.Cells[row.Cells.Count-1]; Label pagerLBL = new Label();
pagerLBL.Text = " (共 " + this.GridView1.PageCount.ToString() + " 页 " + "当前第" + (this.GridView1.PageIndex + 1).ToString() + "页)"; cell.Controls.Add(pagerLBL);
参数名: index
我用了这个语句:row.Cells[10].Controls.Add(pagerLBL);
格式差不多了,1 2 3 4 5 6 7 8 9 10 ... (共 12 页 当前第1页)
这样会不会有问题呢,还有颜色的问题可否提示一下呢!!
你把对应页的Cell的Text加上"<font color='red'></font>应该就可以了把
自己多试试
cell.Text = "<font color='red'>" + cell.Text =+ "</font>"加上这句试试?
加上:
<style>
table tr td table tr td span { color:red; }
</style>
就可以了
<head runat="server">
<title>Untitled Page</title>
<style>
.mycss table tr td table tr td span { color:red; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="mycss">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="ObjectDataSource1" OnRowCreated="GridView1_RowCreated" PageSize="2">
</asp:GridView>
</div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAllResources" TypeName="SooGift.BLL.Auth.Resource">
<SelectParameters>
<asp:Parameter DefaultValue="true" Name="onlyShowInNavigation" Type="Boolean" />
</SelectParameters>
</asp:ObjectDataSource>
</form>
</body>
</html>
所选页数字就是红色的,当然你可以随便设置样式
你寫出來看看呢,學習一下。