水晶报表使用参数

| 我是第一次使用水晶报表。我写的代码如下
public partial class _Default : System.Web.UI.Page 
{
    private ReportDocument report = new ReportDocument();
    protected void Page_Load(object sender, EventArgs e)
    {
        report.Load(Server.MapPath(\"CrystalReport1.rpt\"));
        report.FileName = Server.MapPath(\"CrystalReport1.rpt\");
        if (!Page.IsPostBack)
            {
                BindData();
            }
    }

protected override void OnUnload(EventArgs e)
{
    base.OnUnload(e);
    this.Unload+=new EventHandler(Page_Unload);
}

    public void Page_Unload(object sender, EventArgs e)
    {
        report.Clone();
        report.Dispose();
    }

private void BindData()
    {        
        Trusted_Connection=true\";
        string connectionString = @\"Data Source=WINSERVER;Initial Catalog=card;User       ID=sa;Password = db2admin\";
        SqlConnection myConnection = new SqlConnection(connectionString);
        SqlDataAdapter ad = new SqlDataAdapter(\"SELECT name,address,idno FROM iffcar\", myConnection);
        DataSet ds = new DataSet();
        ad.Fill(ds);
        DropDownList1.DataSource = ds;
        DropDownList1.DataTextField = \"name\";
        DropDownList1.DataValueField = \"idno\";
        DropDownList1.DataBind();
    }


protected void Btn_DisplayReport(object sender, EventArgs e)
    {

    int idno = Convert.ToInt32(DropDownList1.SelectedValue);
    report.SetParameterValue(\"idno\", idno);
    CrystalReportViewer1.ReportSource = report;
    }
}
我在下拉列表中获取值,但是, 现在我的问题是,一旦我从下拉列表中选择一个值,我想报告该值。 怎么做..... 请帮助我解决我的问题。     
已邀请:
尝试使用参数的索引号:
protected void Btn_DisplayReport(object sender, EventArgs e)
{
   int idno = Convert.ToInt32(DropDownList1.SelectedValue);
   report.SetParameterValue(0, idno);
   CrystalReportViewer1.ReportSource = report;
}
    

要回复问题请先登录注册