Hi,
I am trying to print a listview from a web page. It is not a Windows forms listview. Even though the webpage contains many other controls, I am interested in printing only the listview with its items. Could you please let me know how to do this?
Thanks and Regards,
Mohan
Printing a ListView from a web page
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sam HobbsRank #107 · 20.5K reputationPosted Feb 25, 2010, 6:28 AM EST
Raaj KumarRank #7,836 · 233 reputationPosted Feb 25, 2010, 6:18 AM EST
Using javascript you can do this. Since it is easy to implement.
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('', '', 'letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
This will get the entire listview control and put it inside a new window with all the data This can be used for any control. And on a button click call the javascript.
Here i have a passed the div which holds the Listview control.
Hope this could help you.
Regards,
raaj
Mohan Mudaliar17 reputationPosted Mar 1, 2010, 12:50 AM EST
Thank you. It worked for me.
Regards,
Mohan