0

我做一個程序綁定到我的水晶報表viewr像Crystal報表扔錯誤

DataTable orderDtSrc = GetDataFromdb(txtOrderNo.Text);  
rptViewer.ReportSource = new ReportDocument(); 
       if (orderDtSrc != null) 
       { 
        ReportDocument report = new ReportDocument(); 
        report.Load(Server.MapPath("Design/MyReport.rpt")); 
        report.SetDataSource(orderDtSrc); 
        report.SummaryInfo.ReportTitle = "Report No-" + orderDtSrc.Rows[0]["OrderNumber"].ToString(); 
        rptViewer.ReportSource = report; 
        rptViewer.DataBind(); 
       } 

所以它會得到數據放箭,由用戶提供的訂單號獲取數據GetDataFromdb(txtOrderNo.Text);

第一次調用它會得到報告,並綁定查看器沒有問題,然後如果我在文本框中放置一個新的訂單號,然後單擊顯示報告按鈕調用前一個函數,我得到了這個異常。

Value cannot be null. Parameter name: inputString 

回答

0

入住這

if (orderDtSrc != null && orderDtSrc.Rows.Count >0)