【求教】repeater中实现WEB打印分页
如题:
请带上代码·谢谢 一百分送上·略表心意·谢谢 o(∩_∩)o...
[解决办法]
使用javascript控制?
没做过,D!
[解决办法]
我也想知道
[解决办法]
Managers manager = new Managers();
static int TotalPage = 0;
static int TotalNum = 0;
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
ViewState["count"]=1;
DataList1.DataSource = manager.GetPageInfo(Convert.ToInt32(ViewState["count"]));
DataList1.DataBind();
TotalNum = manager.GetTotalPage();
TotalPage=(TotalNum+99)/100;
}
}
//下一页按钮
protected void btn3_Click(object sender, EventArgs e)
{
if (Convert.ToInt32(ViewState["count"]) < TotalPage)
{
ViewState["count"] = Convert.ToInt32(ViewState["count"]) + 1;
DataList1.DataSource = manager.GetPageInfo(Convert.ToInt32(ViewState["count"]));
DataList1.DataBind();
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('已到尾页')</script>");
}
}
//上一页按钮
protected void btn2_Click(object sender, EventArgs e)
{
if (Convert.ToInt32(ViewState["count"]) > 1)
{
ViewState["count"] = Convert.ToInt32(ViewState["count"]) - 1;
DataList1.DataSource = manager.GetPageInfo(Convert.ToInt32(ViewState["count"]));
DataList1.DataBind();
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"","<script>alert('已在首页')</script>");
}
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
//回到首页
protected void btnS_Click(object sender, EventArgs e)
{
ViewState["count"] = 1;
DataList1.DataSource = manager.GetPageInfo(Convert.ToInt32(ViewState["count"]));
DataList1.DataBind();
}
//最后一页
protected void btn4_Click(object sender, EventArgs e)
{
ViewState["count"] = TotalPage;
DataList1.DataSource = manager.GetPageInfo(Convert.ToInt32(ViewState["count"]));
DataList1.DataBind();
}
[解决办法]
Managers manager = new Managers();
static int TotalPage = 0;
static int TotalNum = 0;
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
ViewState["count"]=1;
DataList1.DataSource = manager.GetPageInfo(Convert.ToInt32(ViewState["count"]));
DataList1.DataBind();
TotalNum = manager.GetTotalPage();
TotalPage=(TotalNum+99)/100;
}
}
[解决办法]
可用CSS控制打印分页,比如你要每隔10行分一页,下面代码说明 :
tr上这样绑定:
<tr <%# (Container.ItemIndex+1)%10==0?"style='page-break-after:always;'":"" %>>
[解决办法]
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function page(page)
{
//用脚本控制
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table bgColor="black" width="976px">
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate><tr bgColor="#99ccff"><td>ID</td><td>姓名</td><td>年龄</td></tr></HeaderTemplate>
<ItemTemplate><tr><td bgColor="#ffffcc"><label><%# Eval("Id") %></label></td><td bgColor="#ffffcc"><label><%# Eval("Name") %></label></td><td bgColor="#ffffcc"><label><%# Eval("Age") %></label></td></tr></ItemTemplate>
<FooterTemplate><tr><td colspan="4" bgColor="#99ccff"><a href="本页" onclick="page("参数为页数")">下一页</a></a></td></tr></FooterTemplate> </asp:Repeater>
</table>
</div>
</form>
</body>
[解决办法]
在页面加载时,得到传过来的页数这个就不用我教了吧.
[解决办法]