问题
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