0

我有一个多页网格视图,我想打印所有页面。

这是我的代码

<asp:GridView ID="verifiedsum" runat="server" AllowPaging="true" PageSize="20" AutoGenerateColumns="false" style="margin-left:100px;width:500px">
    <Columns><asp:BoundField HeaderText="RegNumber" DataField="RegNumber" /></Columns>
    <Columns><asp:BoundField HeaderText="Surname" DataField="Surname" /></Columns>
    <Columns><asp:BoundField HeaderText="Firstname" DataField="Givenname" /></Columns>
    <PagerSettings Visible="false" />
</asp:GridView>
<a style="margin-left:100px">Page: <asp:DropDownList id="PageSelect" runat="server" AutoPostBack="true" OnSelectedIndexChanged="PageSelect_SelectedIndexChanged"></asp:DropDownList></a> 

我正在考虑生成一个 word 文件来导出表格,但是从服务器端调用 word 应用程序也很复杂(我认为)。

有谁知道这是怎么做到的吗?谢谢

4

2 回答 2

0

您可以使用以下代码打印任何服务器控件,例如 GridView、DataGrid、Panel、TextBox 等。

http://www.c-sharpcorner.com/uploadfile/rahul4_saxena/printing-in-Asp-Net/

您可以使用它来打印启用分页的 GridView:

http://www.codeproject.com/Articles/20903/Printing-a-GridView-with-Paging

于 2012-05-17T21:16:52.640 回答
0

这是我所做的

            int verifiedamount = 0;

            string line = "";
            List<CVerifiedList> VerifiedList = yourList
            for (int i = 0; i < VerifiedList.Count; i++)
                if (VerifiedList[i].Verified == "Verified")
                    verifiedamount++;
            Response.Buffer = true;
            Response.AddHeader("", "text/plain");
            Response.AddHeader("Content-Disposition", "attachment;filename=" + "tests.csv");


            foreach (CVerifiedList verified in VerifiedList)
            {
                line = verified.RegNumber.ToString() + ", " + verified.Givenname + ", " + verified.Surname + ", " + verified.Verified+",\""+verified.Reason+"\"\n";
                Response.Write(line);
            }
            Response.Write("Number of verified:" + ", " + verifiedamount + "\n");
            Response.Write("Total amount:" + ", " + VerifiedList.Count);
            Response.End();
于 2013-01-07T19:02:48.847 回答