我有一个来自数据库的gridview,问题是当用户单击打印按钮时,我想打印整个页面,gridview 的每一行以给定格式打印为1 A4 尺寸页面上的3 行。
网格视图
打印格式
我有一个来自数据库的gridview,问题是当用户单击打印按钮时,我想打印整个页面,gridview 的每一行以给定格式打印为1 A4 尺寸页面上的3 行。
网格视图
打印格式
如果你想使用 javascript 所以你可以试试这个
function printItn() {
//In my case i have append gridview in Panel that y..you can put your contentID which is you want to print.
var printContent = document.getElementById('<%= pnlForm.ClientID %>');
var windowUrl = 'about:blank';
var uniqueName = new Date();
var windowName = 'Print' + uniqueName.getTime();
// you should add all css refrence for your Gridview. something like.
var WinPrint= window.open(windowUrl,windowName,'left=300,top=300,right=500,bottom=500,width=1000,height=500');WinPrint.document.write('<'+'html'+'><head><link href="cssreference" rel="stylesheet" type="text/css" /><link href="gridviewcssrefrence" rel="stylesheet" type="text/css" /></head><'+'body style="background:none !important"'+'>');
WinPrint.document.write(printContent.innerHTML);
WinPrint.document.write('<'+'/body'+'><'+'/html'+'>');
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
啤酒花它的帮助
我建议您使用一些报告框架,例如 SSRS/Report-Viewer、Crystal Reports 来生成此类输出。
例如,您可以在 RDLC 文件中创建报告定义,该文件在某些排名函数上具有一个组(以确保三行)并使用 ReportViewer 控件显示它 - 请查看此站点以获取有关 reportviewer 的更多信息:http://gotreportviewer。 com/