简体   繁体   English

如何创建动态RDLC数据表

[英]How to create dynamic RDLC data table

在此处输入图片说明在此处输入图片说明在此处输入图片说明 I need to pass to RDLC (SQL Server Reporting Services) report a data table with only one known column and all other columns are created at run time. 我需要将仅包含一个已知列的数据表传递给RDLC(SQL Server Reporting Services)报告,而所有其他列均在运行时创建。 That is I have column A that is know at design time, but before loading the report i will read values from the database and set these values as columns, may be i have one column and may be much more. 那就是我在设计时知道A列,但是在加载报告之前,我将从数据库中读取值并将这些值设置为列,可能是我只有一列,甚至可能更多。

I tried this : 我尝试了这个:

dsStatementOfAccount.DtEndDayDataTable dtMat = new dsStatementOfAccount.DtEndDayDataTable(); dtMat.Columns.Add("c1"); dtMat.Columns.Add("c2"); DataRow row1 = dtMat.NewRow (); row1["Name"] = "Value for column name in row 1"; row1["c1"] = "a"; row1["c2"] = "a121"[1] dtMat.Rows.Add(row1); DataRow row2 = dtMat.NewRow(); row2["Name"] = "Value for column name in row 2"; row2["c1"] = "bbb"; row2["c2"] = "bbb"; dtMat.Rows.Add(row2);

 dsStatementOfAccount.DtEndDayDataTable dtMat = new dsStatementOfAccount.DtEndDayDataTable();  dtMat.Columns.Add("c1"); dtMat.Columns.Add("c2"); DataRow row1 = dtMat.NewRow (); row1["Name"] = "Value for column name in row 1"; row1["c1"] = "a"; row1["c2"] = "a121"[1] dtMat.Rows.Add(row1); DataRow row2 = dtMat.NewRow(); row2["Name"] = "Value for column name in row 2"; row2["c1"] = "bbb"; row2["c2"] = "bbb"; dtMat.Rows.Add(row2); 

But the report was loaded as the attached image .. How it can be done ? 但是该报告已作为附件图像加载。如何完成?

Thanks 谢谢

You should be able to do this by creating a column group that is grouped by your "NAME" column. 您应该可以通过创建按“ NAME”列分组的列组来做到这一点。

After adding your table to your report, define all static columns. 将表添加到报表后,定义所有静态列。 Then, right-click on the cell where you want the dynamic columns to start at and select "Add Group > Parent Group (Under the column group section)" and choose to Group By "NAME". 然后,右键单击要动态列开始的单元格,然后选择“添加组>父组(在列组部分下)”,然后选择按“名称”分组。 This should produce the desired effect. 这应该产生期望的效果。

EDIT: Attached picture of what it would look like in VS. 编辑:所附图片在VS中的外观。 列分组的演示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM