2016-08-18 87 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 –

相关问题