0

プロジェクト ( http://www.aspdotnet-suresh.com/2012/01/pass-parameters-to-crystal-reports-in.html ) を自分の Web サイトに適用したいと考えています。初めて選択した値のみを取得し、必要なレポートを取得しますが、他の値を選択すると、以前のレポートを取得します。誰でも私を助けることができますか?

default.aspx.cs

protected void btnSearch_Click(object sender, EventArgs e)
{
    //CrystalReportViewer1.RefreshReport();
    ReportDocument reportdocument = new ReportDocument();
    reportdocument.Load(Server.MapPath("CrystalReport.rpt"));
    reportdocument.SetDatabaseLogon("", "", "ghaffar-pc", "Northwind");
    //reportdocument.SetParameterValue("Username", txtUserName.Text);
    reportdocument.SetParameterValue("CategoryID", Convert.ToInt32(txtUserName.Text));
    CrystalReportViewer1.ReportSource = reportdocument;
}

デフォルト.aspx

    <table>
    <tr>
    <td><b>Enter UserName</b></td>
    <td><asp:TextBox ID="txtUserName" runat="server"/></td>
    </tr>
    <tr>
    <td></td>
    <td><asp:Button ID="btnSearch" runat="server" Text="Search" onclick="btnSearch_Click" /></td>
    </tr>
    </table>

</div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
    EnableDatabaseLogonPrompt="False" AutoDataBind="true" ReuseParameterValuesOnRefresh="False"
    EnableParameterPrompt="False" ToolPanelView="None" />

レポートを表示するために選択した値に関係なく、CrystalReport.rpt ファイルで必要な結果が得られることに注意してください。

4

2 に答える 2

0

電話

reportdocument.Refresh();

次のstmtのすぐ上。

CrystalReportViewer1.ReportSource = reportdocument;
于 2012-07-27T18:02:54.193 に答える