Hi Friends,
I have a page with searching relevant parameters with Gridview listing.The gridview is placed inside a div which has scroll bars. When i click to print button, i want to print gridview data. How can i do this?
help me if u have any idea?
Thanks in advance
Dinesh Kumar
Gridview Print
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Lalit MRank #1,186 · 1.5K reputationPosted Dec 8, 2009, 6:46 PM EST
1) create simple web application (here i used asp.net with C#).
2) put following control in to Page.
1) Gridview (id = GridView1)
2) html button (id =Button1)
<inputid="Button1?type="button"value="Print"language="javascript"onclick="return Button1_onclick()" />
<asp:GridViewID="GridView1?runat="server">
asp:GridView>
3) fill data into GridView
//here i used the list you can bind with database also
System.Collections.Generic.List<string> obj = newSystem.Collections.Generic.List<string>();
for(inti = 0; i < 10; i++)
{
obj.Add(i.ToString());
}
GridView1.DataSource = obj;
GridView1.DataBind();
4) now write the print function. click on the Button1 or write Java Script.
script language="javascript" type="text/javascript"> function Button1_onclick() { //open new window set the height and width =0,set windows position at bottom var a = window.open ('','','left =' + screen.width + ',top=' + screen.height + ',width=0,height=0,toolbar=0,scrollbars=0,status=0'); //write gridview data into newly open window a.document.write(document.getElementById('').innerHTML); a.document.close(); a.focus(); //call print a.print(); a.close(); return false; } // --> script>Reference link1 .. Thanks ...