Thursday, December 10, 2009

Printing documents with GridView in IE

It's a good idea using ASP.NET web based systems for inventory and business control. But any browser is not a good place for printing documents.
I had a bit of a problem in printing GridView in Internet Explorer. I needed to print only two rows on one page. The first problem was how to break page. I used the special style
"page-break-before:always;" for the tag "br". The second problem was how to insert this unit before each odd row but exclude the first row. I used the property Container.DataItemIndex And now we have this very simple solution:
<asp:gridview....

<Itemtemplate >

<%#IIf(Container.DataItemIndex Mod 2 = 0 AND Container.DataItemIndex <> 0, "<br style=""page-break-before:always;""> ", "<br> ")%>
<div>..information....</div >
</Itemtemplate >
If you will print this gridview you will have only two rows on each page

No comments:

Post a Comment