我有一个从数据库中填充的数据网格视图。在表格中,文本框和下拉列表中很少有列可以获得用户输入。我想将所有这些数据传递到水晶报表而不插入数据库 并打印为报表中的表格。可以更改行的数量。所以我不能设计它的表。所以我想打印水平线以分隔细节(不需要垂直线)。我该怎么办? 在这里,我添加了 aspx 代码
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>
&#13;
答案 0 :(得分: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(" "))
dr[grdReport.Columns[j].ToString()] = row.Cells[j].Text;
}
_datatable.Rows.Add(dr);
}
ExportDataTableToPDF(_datatable);
}
此处将数据绑定到Crystal报表
void ExportDataTableToPDF(Datatable _datatable)
{
}