水晶报表翻页问题

上图:[img=http://http://hi.csdn.net/attachment/201108/5/2013184_1312539276Gzdz.jpg][/img]
前台aspx页代码:
[code=C#]<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="Reporting_Report" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Assembly="WebControlLibrary" Namespace="WebControlLibrary" TagPrefix="ph" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>我的水晶报表</title>
    <link href="../style/z_style.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" src="../Calendar/WdatePicker.js"></script>
    <script language="javascript" type="text/javascript" src="../js/comm.js"></script>
    <script language="javascript" type="text/javascript" src="../js/date.js"></script>
    <script language="javascript" type="text/javascript">
        function preview(oper)
        {
            bdhtml=window.document.body.innerHTML;  //获取当前页的html代码
            sprnstr="<!--startprint"+oper+"-->";  //设置打印开始区域
            eprnstr="<!--endprint"+oper+"-->";  //设置打印结束区域
            prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18);   //从开始代码向后取html

            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));  //从结束代码向前取html
            window.document.body.innerHTML=prnhtml;
            window.print();
            window.document.body.innerHTML=bdhtml;
        }
        
          function Print()   
        {    
         var str = document.getElementById("tbPrint").innerHTML;
         str = "<link href=\"../style/z_style.css\" rel=\"stylesheet\" type=\"text/css\" /><table id=\"tbPrint\" style=\"margin-top:30px;margin-left:12px\"  width='1000' border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"3\">" + str +"</table>";
         var pwin=window.open("Print.htm","print");    
         pwin.document.write(str);
         pwin.document.close();                   
         pwin.print();    
        }
      </script>
    <style type="text/css">
     #Table1{ padding:0px; margin:0px;}
     #Table1 tr{border: 1px none #91C5EC;}
     #Table1 tr td{border: 1px none #91C5EC;overflow:hidden}
     .Dtable_sun{width:100%; text-align:left;border-top:1px solid #aaaaaa;position:relative}
     .mune_sun{height:32px; overflow:hidden; background:#f4deb3; width:778px; position:absolute;border:1px solid #91c5ec;}
     .mune_sun div{ float:left; font-weight:bold; line-height:30px; text-align:center;}
     .dtable_content{float:left; height:100%;vertical-align:middle;  }
     .sun_content{margin:0 auto; text-align:left; overflow:hidden; width:100%; padding-top:30px; border:1px solid #91c5ec;}
    
    </style>   
</head>
<body>
 <form id="form1" runat="server">
  <table border="0" cellspacing="5" cellpadding="0" width="1000px">
      <tr>
     <td style="height:40px; padding-top:10px; padding-right:10px; vertical-align:top; width:100%;">
     
      <table width='100%' border='0' cellpadding='0' cellspacing='0' οnclick='parent.leftmenu_ctrl();'class='moduleTitle'>
        <tr>
         <td valign='top'><h2>Business Travel Summary Enquiry:</h2></td>
         <td valign='top' align='right' style='padding-top: 3px; padding-left: 5px;'><span style="padding-right: 10px;">Reporting &gt;&gt;&nbsp;Business Travel Summary Enquiry</span></td>
        </tr>
      </table><br />
      
      <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tabForm">
        <tr>
         <td>
          <table width="100%" border="0" cellpadding="0" cellspacing="3">
           <tr>
            <td align="right" rowspan="3">&nbsp;&nbsp;</td>
            <td style="width: 20%;">Staff Name:</td>
            <td class="dataField" style="text-align: left; width: 30%;"><asp:TextBox ID="txtStaffId" runat="server" MaxLength="50"></asp:TextBox>
             </td>
           <td style="width: 17%;">Division:</td>
           <td class="dataField" style="width: 33%;">
               <asp:DropDownList ID="dlDep" runat="server" DataTextField="Dept" DataValueField="DeptId" CssClass="select">
                   <asp:ListItem Value="All">-All-</asp:ListItem>
                   <asp:ListItem>OPS</asp:ListItem>
                   <asp:ListItem>COM</asp:ListItem>
                   <asp:ListItem>COR/RET</asp:ListItem>
                   <asp:ListItem>GPX</asp:ListItem>
                   <asp:ListItem>PRO</asp:ListItem>
                   <asp:ListItem>PTR</asp:ListItem>
                   <asp:ListItem>RET</asp:ListItem>
                   <asp:ListItem>COR</asp:ListItem>
               </asp:DropDownList>
           </td>
          </tr>
          <tr>
           <td>Travel City:</td>
           <td class="dataField">
               <br />
               <asp:TextBox ID="txtCity" runat="server"></asp:TextBox></td>
           <td>Travel Period:<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
               &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br /> TO:
            </td>
           <td class="dataField"><ph:InputCalendar ID="dtT1" runat="server" CssClass="Wdate" />
               <br />
               <ph:InputCalendar ID="dtT2" runat="server" CssClass="Wdate" /></td>
          </tr>
          <tr>
           <td style="height: 22px">Personal Trip Portion:</td>
           <td colspan="3" style="height: 22px">
               <ph:InputCalendar ID="dtp1" runat="server" CssClass="Wdate" />To<ph:InputCalendar ID="dtp2" runat="server"  CssClass="Wdate" />
           </td>
          </tr>
          <tr>
           <td height="40" colspan="5" align="center">
               &nbsp;<asp:Button ID="btnSearch" runat="server" CssClass="button" Text=" Search " OnClick="btnSearch_Click" /> &nbsp;
               <asp:Button ID="btnReset" runat="server" Text="Reset" CssClass="button" OnClick="btnReset_Click"   />&nbsp;
               <input class="button" type="button" name="clear" value=" Print " οnclick="Print()" id="Button1" />
           </td>
          </tr>
        </table>
      </td>
     </tr>
    </table><br />
    

    
      <table border="0" cellspacing="0" cellpadding="0" width="100%">
          <tr>
              <td>
                 <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" Height="50px" Width="350px" DisplayGroupTree="False" />&nbsp;
                  <br />
                 <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
                  </CR:CrystalReportSource>
              </td>
          </tr>
          
      </table>
 
     </td>    
      </tr>
  </table>
 
 </form>
</body>
</html>
[/code]
后台aspx.cs代码:
[code=C#]
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.Sql;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;


public partial class Reporting_Report : System.Web.UI.Page
{
    public string connstr = @"server=infowise-pc;uid=sa;pwd=2009;database=eTne0701;Persist Security Info=True;";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["Hashtable"] = null;
            Session["FromCity"] = null;
            Session["Hashtable1"] = null;
            Session["FromCity1"] = null;
            Session["TripAppCode"] = null;
        }

    }

    public void ConfigureCrystalReports()
    {
        string sqlconnstr = "select StaffId,StaffName,TrvFromdatetime,TrvTodatetime,Departure,Arrival,NoOfDays,FromCity,ToCity,AirRem,TripAppCode from v_TravelEnquiry";
        SqlDataAdapter da = new SqlDataAdapter();
        SqlConnection conn = new SqlConnection(connstr);
        da = new SqlDataAdapter(sqlconnstr, conn);

        DataSet dt = new DataSet();
        da.Fill(dt, "myTable");
        conn.Close();
        CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
        CrystalReportSource1.ReportDocument.SetDataSource(dt.Tables["myTable"]);
        CrystalReportSource1.DataBind();


    }
    private void Page_Init(object sender, EventArgs e)
    {
        ConfigureCrystalReports();

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if (dlDep.SelectedValue == "All")
        {
            CrystalReportViewer1.ReportSource = CrystalReportSource1;
            CrystalReportViewer1.DataBind();
        }
        else
        {
            if (dlDep.SelectedValue == "OPS")
            {
                string opstr = "select StaffId,StaffName,TrvFromdatetime,TrvTodatetime,Departure,Arrival,NoOfDays,FromCity,ToCity,AirRem,TripAppCode from v_TravelEnquiry WHERE Dept='OPS'";
                SqlConnection conn = new SqlConnection(connstr);
                SqlDataAdapter da = new SqlDataAdapter();
                da = new SqlDataAdapter(opstr, conn);
                DataSet ds = new DataSet();
                da.Fill(ds, "myTable");
                conn.Close();

                CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["myTable"]);
                CrystalReportSource1.DataBind();
                CrystalReportViewer1.ReportSource = CrystalReportSource1;
                CrystalReportViewer1.DataBind();
            }
            if (dlDep.SelectedValue=="COM")
             {
              string comstr = "select StaffId,StaffName,TrvFromdatetime,TrvTodatetime,Departure,Arrival,NoOfDays,FromCity,ToCity,AirRem,TripAppCode from v_TravelEnquiry WHERE Dept='COM'";
              DataSet ds = new DataSet();
              SqlConnection conn = new SqlConnection(connstr);
              SqlDataAdapter da = new SqlDataAdapter(comstr,conn);
              da.Fill(ds, "myTable");
              conn.Close();
              CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["myTable"]);
              CrystalReportSource1.DataBind();
              CrystalReportViewer1.ReportSource = CrystalReportSource1;
              CrystalReportViewer1.DataBind();
             }
             if (dlDep.SelectedValue=="COR/RET")
              {
                  string corstr = "select StaffId,StaffName,TrvFromdatetime,TrvTodatetime,Departure,Arrival,NoOfDays,FromCity,ToCity,AirRem,TripAppCode from v_TravelEnquiry WHERE Dept='COR/RET'";
                  DataSet ds = new DataSet();
                  SqlConnection conn = new SqlConnection(connstr);
                  SqlDataAdapter da = new SqlDataAdapter(corstr,conn);
                  da.Fill(ds,"myTable");
                  conn.Close();
                  CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["myTable"]);
                  CrystalReportSource1.DataBind();
                  CrystalReportViewer1.ReportSource = CrystalReportSource1;
                  CrystalReportViewer1.DataBind();
                  
              }
        }
    }




    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtStaffId.Text = "";
        dlDep.SelectedValue = "All";
        txtCity.Text = "";
        dtT1.Value = "";
        dtT2.Value = "";
        dtp1.Value = "";
        dtp2.Value = "";
    }
}

[/code]

出现的问题:报表可以根据搜索条件显示数据,但是点下一页或最后一页时出现不显示报表的Bug,如下图:
[img=http://hi.csdn.net/attachment/201108/5/2013184_13125402464GZ4.jpg][/img]
希望泰哥出售帮忙啊...感谢.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值