2012-05-17 174 views
0

我有一個多頁面gridview,我想打印所有頁面。打印多頁面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

這裏是我做過什麼

  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();