【发布时间】:2014-12-02 05:34:06
【问题描述】:
我正在使用 Visual Studio 2010,并且我在没有使用报告向导的情况下创建了一个 rdlc 报告并将数据集添加到其中,但是当我右键单击文本框时,选择表达式然后导航到数据集,我可以看到我的数据集已添加到报告中但是当我单击字段时,它显示“报告项目未链接到数据集”。我在 VS 2008 中没有遇到这个问题,并且报告在其中正常工作。我不知道如何在VS2010中解决这个问题。所以有人帮助我解决这个问题。我附上了下面问题的屏幕截图。请检查一下。
下面给出了我用来在表格中显示值的代码,但我想知道如何在文本框而不是表格中显示值。
protected void Page_Load(object sender, EventArgs e)
{
LocalReport lr = null;
DataSet ds = new DataSet();
con.Open();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter("Select CatalogNo as CatalogNo, Productname as ProductName, Quality_Plan_Ref_No as QPRefNo,Drawing_No as DrawingNo,ISR_No as ISRNo,BatchNo as BatchNo,Allotted_Qty as AllottedQty,CONVERT(VARCHAR(10),Allotted_Date,105) as AllottedDate from Batch_Allott where CatalogNo='0464' ", con);
da.Fill(ds, "temp");
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
lr = ReportViewer1.LocalReport;
lr.ReportPath = "Report1.rdlc";
lr.DataSources.Add(new ReportDataSource("Dataset1_Batch_Allott", ds.Tables[0]));
}
【问题讨论】:
-
您可以使用 =First(Fields!CatalogNo.Value,"DataSetName") 因为我认为您的文本框不在 Tablix 或 ListView 中,因此您必须通过聚合表达式引用数据集
-
@Sandeep 为什么在我使用您建议的说明时出现红线。在问题中查看我更新的图片。
-
我不知道为什么它显示红线可能是因为语义错误,但如果你运行报告它会起作用
-
@Sandeep 我在 Allotted_Date 中有一个日期列表,我必须根据我通过查询的目录显示一个特定的日期。你能解释一下如何与示例代码一起执行此操作。
-
我假设当您按目录号过滤时,数据集中的最终结果将只有 1 行。在这种情况下,您可以使用 First,但如果数据集包含多行,则必须使用 Tablix 或 ListView,或者您必须使用其他聚合函数,如 Min、Max、Avg 等。
标签: c# asp.net visual-studio-2010 reporting-services