如何在每个打印页面上打印GridView的标题 [英] How to print header of GridView on each print page
问题描述
如何在每个打印页面上打印网页标题和 GridView
的标题?
How do I print the page title and the header of a GridView
on each print page?
I要在每一页上添加页面标题和 GridView
标题。
I want to add page title and GridView
heading on each page.
我使用分页符打破 GridView
到多个页面,但只有第一页带有标题,所有其他都没有标题页和标题页。
I used page break to break the GridView
into multiple pages, but only the first page comes with title and all other are without header and title page.
动态 GridView
,我的代码使用 AutoGenerateColumns =true
推荐答案
将以下内容放在头部
<style media="print">
.MyCssClass thead
{
display: table-header-group;
}
</style>
现在把你的gridview放在div中,并给div类名MyCssClass
Now put your gridview in a div and give the div the class name MyCssClass
现在添加GridView1_RowDataBound事件,并在该事件中调用传递Gridview对象的以下函数。
Now add the GridView1_RowDataBound event and in that event call the below function passing the Gridview object.
private void MakeGridViewPrinterFriendly(GridView gridView)
{
if (gridView.Rows.Count > 0)
{
gridView.UseAccessibleHeader = true;
gridView.HeaderRow.TableSection = TableRowSection.TableHeader;
//gridView.HeaderRow.Style["display"] = "table-header-group";
}
}
这适用于IE和FF。未在Chrome中测试。
this works with IE and FF. not tested in Chrome.
这篇关于如何在每个打印页面上打印GridView的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!