.net 如何将一列添加到 rdlc 的数据集中并让它出现在报告中以供使用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4444620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I add a column to an rdlc's dataset and have it appear for use in the report?
提问by Mark Avenius
I have an rdlc that has a separately-defined dataset. The time has come that I have the need to add a column to one of the tables, which I can do without issue. However, when I open the rdlc to use the new column, it does not appear in the Report Data pane.
我有一个 rdlc,它有一个单独定义的数据集。现在是我需要向其中一个表添加一列的时候了,我可以毫无问题地做到这一点。但是,当我打开 rdlc 以使用新列时,它不会出现在“报告数据”窗格中。
This issue was reported to Microsoft here, but it was closed as by design. The workaround offered with the issue does not seem to work for VS2010 (refresh the dataset or the table; neither does anything).
此问题已在此处报告给 Microsoft ,但已按设计关闭。该问题提供的解决方法似乎不适用于 VS2010(刷新数据集或表;也没有任何作用)。
Has anyone seen this problem, and if so, how did you get around it?
有没有人看到过这个问题,如果有,你是如何解决的?
采纳答案by Mark Avenius
Well, I resolved my problem, but I don't like how I had to do it.
好吧,我解决了我的问题,但我不喜欢我必须这样做。
For reference, (as far as I can tell) the only way to add a column to a dataset that is already attached to an rdlc is to hand-edit the xml (i.e. open the rdlc with your favorite text editor and add a Fieldto the appropriate table). After doing this, the field appears in the Report Datapane, and I can use it as if it were there from the beginning.
作为参考,(据我所知)将列添加到已经附加到 rdlc 的数据集的唯一方法是手动编辑 xml(即使用您喜欢的文本编辑器打开 rdlc 并将 a 添加Field到适当的表)。执行此操作后,该字段将出现在Report Data窗格中,我可以使用它,就好像它从一开始就在那里一样。
I would still like to know how to perform this seemingly simple task from the UI, but nonetheless my current problem is solved.
我仍然想知道如何从 UI 执行这个看似简单的任务,但我目前的问题已经解决了。
回答by Aranda
For those people who googled and got here, the Report Data panel is often hidden and can be found in the menu under View -> Report Data (Ctrl + Alt +D)... it's right at the bottom: http://www.codeease.com/about-update-dataset-for-a-rdlc-file-in-visual-studio-2010.html
对于那些用谷歌搜索并到达这里的人来说,报告数据面板通常是隐藏的,可以在查看 -> 报告数据(Ctrl + Alt + D)下的菜单中找到......它就在底部:http://www .codeease.com/about-update-dataset-for-a-rdlc-file-in-visual-studio-2010.html
Once that's up you can right click on the report data sets and refresh or edit them. This has always worked for me (once I remember and find the Report Data panel!), so I'm not sure why it didn't work for the OP.
完成后,您可以右键单击报告数据集并刷新或编辑它们。这一直对我有用(一旦我记得并找到“报告数据”面板!),所以我不确定为什么它对 OP 不起作用。
回答by disklosr
Quick workaround I found for VS 13 users (not tested in other versions):
我为 VS 13 用户找到的快速解决方法(未在其他版本中测试):
- Make the change you want in your class (add/remove/rename properties)
- Build the project
- Unload the report project
- Reload the report project
- Open the report rdlc file
- Make sure your Report Data window is visible, if not find it hidden at the bottom in the view menu
- Right click your data set and click 'Refresh', it will now work
- 在班级中进行所需的更改(添加/删除/重命名属性)
- 构建项目
- 卸载报表项目
- 重新加载报表项目
- 打开报告 rdlc 文件
- 确保您的报告数据窗口是可见的,如果没有发现它隐藏在视图菜单的底部
- 右键单击您的数据集并单击“刷新”,它现在可以工作了
回答by jamcastillo
I'm using VS 2010.
我正在使用 VS 2010。
On Solution Explorer
在解决方案资源管理器上
- Double click the .xsd file where your rdlc report is connected.
- Right Click > Configure
- Click Query Builder > Check/Select the fields you needed.
- Next > Next > Finish then Save.
- 双击连接 rdlc 报告的 .xsd 文件。
- 右键单击 > 配置
- 单击查询生成器 > 检查/选择您需要的字段。
- 下一步 > 下一步 > 完成然后保存。
On RDLC Report
关于 RDLC 报告
- Press CTRL + ALT + D.
- On Report Data, right click DataSet then Refresh.
- 按 CTRL + ALT + D。
- 在报表数据上,右键单击数据集,然后单击刷新。
回答by user4303149
This is for VS 2010.
这是针对VS 2010 的。
Watch out for menu "Data" in Slandered menu.
注意诽谤菜单中的菜单“数据”。
Data--> Show Data Sources
数据-->显示数据源
You will get options to refresh the RDLCData Source and all options related.
您将获得刷新RDLC数据源和所有相关选项的选项。
回答by Tech Bangalore
The easiest way I found is, if somebody out there is still looking for an answer, add a new Data Source (the xsd), on Report Data pane==>right click on Datasets ==>Add Dataset, the Dataset Properties dialog will appear. Create a new dataset, this time it will populate all the columns from table/stored proc. Once the dataset is added, exclude the old dataset, rename it to something else, through windows explorer or command prompt. Now exclude the newly added dataset, rename it to the old dataset name and include it back to the project. The data gets refreshed.
我发现的最简单的方法是,如果有人仍在寻找答案,请在“报告数据”窗格==>右键单击“数据集”==>“添加数据集”,添加新数据源(xsd),“数据集属性”对话框将出现。创建一个新数据集,这次它将填充 table/stored proc 中的所有列。添加数据集后,通过 Windows 资源管理器或命令提示符排除旧数据集,将其重命名为其他名称。现在排除新添加的数据集,将其重命名为旧数据集名称并将其包含回项目。数据得到刷新。
回答by Geoff Collishaw
I am using VS 2008. THere's no View | Report Datain the menu. So, I hacked the RDLC file using NotePad. Some sections are binary, but some sections are xml. One of the xml sections lists the datafields. I just added one at the bottom of the list and changed the name and datatype as appropriate. I referenced the Dataset in my VS project so I got the right datatype and name. All works fine now.
我正在使用 VS 2008。没有视图 | 菜单中的报告数据。因此,我使用 NotePad 破解了 RDLC 文件。有些部分是二进制的,但有些部分是 xml。xml 部分之一列出了数据字段。我只是在列表底部添加了一个,并根据需要更改了名称和数据类型。我在我的 VS 项目中引用了数据集,所以我得到了正确的数据类型和名称。现在一切正常。
回答by Do Tu Tai
Open file rdlc in Visual Studio, then click View(in top menu) --> Data Report, in panel Data Report,right click into Data Sources/Report Datasetthen click refresh.
在 Visual Studio 中打开文件 rdlc,然后单击View(in top menu) --> Data Report,在面板Data Report 中,右键单击进入Data Sources/Report Dataset然后单击refresh。

