2

我有一个来自数据库的gridview,问题是当用户单击打印按钮时,我想打印整个页面,gridview 的每一行以给定格式打印为1 A4 尺寸页面上的3 行。

网格视图 在此处输入图像描述

打印格式 在此处输入图像描述

4

2 回答 2

4

如果你想使用 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();
                    }

啤酒花它的帮助

于 2012-03-15T12:37:28.850 回答
0

我建议您使用一些报告框架,例如 SSRS/Report-Viewer、Crystal Reports 来生成此类输出。

例如,您可以在 RDLC 文件中创建报告定义,该文件在某些​​排名函数上具有一个组(以确保三行)并使用 ReportViewer 控件显示它 - 请查看此站点以获取有关 reportviewer 的更多信息:http://gotreportviewer。 com/

于 2012-03-15T04:51:16.213 回答