我对打印一个asp网格有一些疑问。 [英] I had some doubt in print a asp grid.
本文介绍了我对打印一个asp网格有一些疑问。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的asp页面中,我有一个带有一些信息的网格,我想要打印网格。所以我写这个编码
In my asp page i had one grid with some information and i want to print the grid. So I write this coding
<div id="gvDiv">
<asp:GridView ID="gvPrint" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="cardname" HeaderText="cardname"
SortExpression="cardname" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" ReadOnly="True"
SortExpression="Quantity" />
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
<asp:Button ID="btnPrint" runat="server" Text="Print Data"/>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ grid(); }
string printScript = @"function PrintGridView()
{
var gridInsideDiv = document.getElementById('gvDiv');
var printWindow = window.open('gview.htm','PrintWindow','letf=0,top=0,width=150,height=300,toolbar=1,scrollbars=1,status=1');
printWindow.document.write(gridInsideDiv.innerHTML);
printWindow.document.close();
printWindow.focus();}";
this.ClientScript.RegisterStartupScript(Page.GetType(), "PrintGridView", printScript.ToString(), true);
btnPrint.Attributes.Add("onclick", "PrintGridView();");
但它没有打印网格请有人帮助我........
But It doesn''t print the Grid please some one help me........
推荐答案
尝试使用水晶报告打印数据。
Try crystal reports for printing data.
这篇关于我对打印一个asp网格有一些疑问。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文