用RDLC做報表時,在數據源中增加了一個字段,相應的報表上添加了一個文本框,將其value值設置為那個字段后,編譯時總是報錯:報表項表達式只能引用當前數據集作用域內的字段或指定數據集作用域內的字段(如果該表達式包含在聚合函數中)。
后來發現要將報表文件打開,那里面少了相應的節點:
<Field Name="****">
<DataField>****</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
添加參數時也要添加相應的節點:
<ReportParameter Name="****">
<DataType>String</DataType>
<AllowBlank>true</AllowBlank>
<Prompt>Report_Parameter_**</Prompt>
</ReportParameter>
特此記錄!
附C# ReportViewer報表 詳解 http://blog.csdn.net/keisuoy/article/details/1731528