<script language="javascript"> function doPrint() { var prtContent = document.getElementById('<%= GridView1.ClientID %>'); prtContent.border = 0; //set no border here var WinPrint = window.open('','','left=0,top=100,width=80,height=100,toolbar=0,scrollbars=1,status=0,resizable=1'); WinPrint.document.write(prtContent.outerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); } </script> <asp:Button ID="Button2" runat="server" ForeColor="#FF8000" OnClientClick="doPrint()" OnClick="Button2_Click" Style="z-index: 101; left: 896px; position: absolute; top: 80px" Text="Print" Width="80px" /> <asp:GridView ID="GridView1" runat="server" Height="280px" Style="z-index: 103; left: 64px; position: absolute; top: 96px" Width="240px"> </asp:GridView> protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { filldata(); } protected void filldata() { SqlConnection con = new SqlConnection("Data Source=VER;Initial Catalog=Company;Min Pool Size=5;Max Pool Size=100000;Connect Timeout=100000;User ID=sa;Password=103"); SqlDataAdapter da = new SqlDataAdapter("select Itemkey,Item,Quantity from temp where TransferNo=" + Convert.ToInt32(Session["TransferNo"].ToString()) + "", con); DataSet ds = new DataSet(); da.Fill(ds, "temp"); if (ds != null && ds.Tables != null && ds.Tables[0].Rows.Count > 0) { GridView1.DataSource = ds.Tables["temp"]; GridView1.DataBind(); } } }
|