我有一个多页面gridview,我想要打印所有页面。
这是我的代码
<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应用程序也很复杂(我认为)。
有谁知道怎么做?感谢
答案 0 :(得分: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
答案 1 :(得分: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();