2016-08-18 100 views
-2

我有一個數據網格視圖從數據庫 pupple。在該表中,有幾個列,其從獲得用戶輸入文本框下拉列表。我想將所有這些數據傳遞給水晶報告而不插入到數據庫中打印在報告內的表中。 可以更改。所以我不能在其中設計表格。所以我想打印水平線來分開細節(垂直線不需要)。我該怎麼做?
在這裏,我已經加了我的aspx代碼如何將GridView中的詳細信息傳遞給報表?

ASPX代碼

<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White" 
 
        runat="server" AutoGenerateColumns="False" Style="margin-left: 20px; margin-right: 20px; 
 
        margin-top: 10px" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" 
 
        BorderColor="#999999" BorderStyle="Solid" BorderWidth="2px"> 
 
        <%--OnRowDataBound="OnRowDataBound" OnRowEditing="OnRowEditing--%> 
 
        <Columns> 
 
         <asp:BoundField DataField="chdrnum" HeaderText="Client Num" ItemStyle-Width="90"> 
 
          <ItemStyle Width="90px" /> 
 
         </asp:BoundField> 
 
         <asp:BoundField DataField="CCDATE" HeaderText="Risk Date" ItemStyle-Width="90"> 
 
          <ItemStyle Width="90px" /> 
 
         </asp:BoundField> 
 
         <asp:BoundField DataField="SUMIN" HeaderText="Sum Assured" ItemStyle-Width="90"> 
 
          <ItemStyle Width="90px" /> 
 
         </asp:BoundField> 
 
         <asp:BoundField DataField="SINSTAMT06" HeaderText="Premiums" ItemStyle-Width="90"> 
 
          <ItemStyle Width="90px" /> 
 
         </asp:BoundField> 
 
         <asp:BoundField DataField="PTDATE" HeaderText="Next Due Date" ItemStyle-Width="90"> 
 
          <ItemStyle Width="90px" /> 
 
         </asp:BoundField> 
 
         <asp:TemplateField HeaderText="Surrender Value"> 
 
          <ItemTemplate> 
 
           <asp:TextBox ID="txtSVal" runat="server" Style="width: 100px; margin-left: 5px; background-color: Transparent"></asp:TextBox> 
 
          </ItemTemplate> 
 
         </asp:TemplateField> 
 
         <asp:TemplateField HeaderText="Loan Outstanding"> 
 
          <ItemTemplate> 
 
           <asp:TextBox ID="txtLoan" runat="server" Style="width: 110px; margin-left: 5px; background-color: Transparent"></asp:TextBox> 
 
          </ItemTemplate> 
 
         </asp:TemplateField> 
 
         <asp:TemplateField HeaderText="Age Admitted"> 
 
          <ItemTemplate> 
 
           <asp:DropDownList ID="ddlAge" runat="server" Style="width: 80px; margin-left: 5px; 
 
            background-color: Transparent"> 
 
            <asp:ListItem Text="- Select -" Value="- Select -" /> 
 
            <asp:ListItem Text="Yes" Value="Yes" /> 
 
            <asp:ListItem Text="No" Value="No" /> 
 
           </asp:DropDownList> 
 
          </ItemTemplate> 
 
         </asp:TemplateField> 
 
        </Columns> 
 
        <HeaderStyle BackColor="#3AC0F2" ForeColor="White" /> 
 
        <AlternatingRowStyle BackColor="#3AC0F2" /> 
 
       </asp:GridView>

+0

晶體使用交叉表報告 – Siva

+0

我想通過在GridView中的數據。設計不是問題 – Mike

回答

0

先轉換你的GridView到DataTable中

protected void btnExportCrstalReport_Click(object sender, EventArgs e) 
    { 
     DataTable _datatable = new DataTable(); 
     for (int i = 0; i < grdReport.Columns.Count; i++) 
     { 
      _datatable.Columns.Add(grdReport.Columns[i].ToString()); 
     } 
     foreach (GridViewRow row in grdReport.Rows) 
     { 
      DataRow dr = _datatable.NewRow(); 
      for (int j = 0; j < grdReport.Columns.Count; j++) 
      { 
       if (!row.Cells[j].Text.Equals("&nbsp;")) 
        dr[grdReport.Columns[j].ToString()] = row.Cells[j].Text; 
      } 

      _datatable.Rows.Add(dr); 
     } 
     ExportDataTableToPDF(_datatable); 
    } 

這裏綁定Dataable水晶報表

void ExportDataTableToPDF(Datatable _datatable) 
    { 
    } 
+0

感謝您的回答。我會試試這個 – Mike

+0

什麼是「grdReport」? – Mike

+0

grdReport是Gridview –

相關問題