How can I change the column order of a SQL Server Report Services report at runtime?

三世轮回 提交于 2019-12-24 15:21:14

问题


I would like to change the sequence of the headers/columns of an *.rdlc report at runtime based on e.g. user preference settings. I found that you can make some columns invisible, but I haven't found a way to change the order of the columns. I am using the ReportViewer control in an ASP.NET web page. And at runtime in this case would mean that the layout can change during two page requests. I read somewhere that you could configure the rdlc xml dynamically or use the rdl object model to create the report definition dynamically as part of the request handling.

The following example should will hopefully explain better what I am trying to do:

Default report column layout of a table or matrix:

Date   Item   Price

Dynamically changed order of columns at runtime:

Item   Price   Date

回答1:


The only way I've ever done something similar is through parameters.

Header cell expression: =Parameters!Column1.Label
Row cell expression:    =Fields(Parameters!Column1.Value).Value

Where the label parameter is the column header and the value is the Field name in your dataset. So in your example there would be 3 Column parameters, all with the available label/value of Date, Item, Price and changing the parameters will determine the column contents.



来源:https://stackoverflow.com/questions/9724812/how-can-i-change-the-column-order-of-a-sql-server-report-services-report-at-runt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!