Dynamic column header generation on RDLC report RRS feed

  • Question




    I have a dataset which gets populated with columns and the rows during the runtime. I cant even expect a certain number of columns on it- that is also dynamic. I need to generate the column headers and show the values of this dataset on a report table. Any way I can accomplish this?


    Thanks very much.

    Tuesday, December 4, 2007 8:15 AM


All replies

  • Yes.
    You can genereate rdlc dynamically.



    Wednesday, December 5, 2007 4:07 AM
  • Hello Asle81,


    Were you suceessfull in dynamically generating columns in .rdlc.

    I have a similar situation were i have some textbox in .rdlc.


    Now during runtime i would like to populate these textbox with my column data of datatable i generate

    at runtime.


    Its possible to bind textboxes in .rdlc during design time but my datatable only gets generated at runtime.



    Wednesday, December 5, 2007 6:13 AM
  • Please see

  (current messages in thread, towards the end, address this problem)


    Wednesday, December 5, 2007 5:34 PM

    Did you create the parameter in the .RDLC template?   In order to create a parameter in the have to right click in the grey area below the report and choose parameters....then you can declare any parameters you want to use in the .rdlc.   You really only need to set a name and type, the prompt is only used in conjunction with .RDL files not .RDLC files.
    Monday, December 10, 2007 2:10 PM
  • Hi,


    Yes it works perfactly.

    But when i want to pass an array of string as parameter to a table in .rdlc i am not able to figure out how to do that.

    Also when i try to do that a compile time error appears.


    The table ‘table1’ is in the report body but the report has no data set.  Data regions are not allowed in reports without datasets.


    Any way out of this as i want to dynamically add data to .rdlc table and not design time.



    Tuesday, December 11, 2007 9:20 AM
  • (sorry for the delay, I am moving house).


    The way around your second issue is to create a dummy or representative dataset at design time and swap it out at runtime. It's quite easy to do this, using literals of the appropriate datatypes for each column (you only need one row).


    On your first issue, is this really an RDLC or an RDL? Are you passing the parameter "to a table" or "to the report"?  If it's really an RDLC, you're preparing the data outside the report, so, although you can use parameters in RDLCs, you typically wouldn't be using parameters to configure the data for a table... unless you're using this for a table filter, is that it?


    More specifics, please, and an example of what you are doing, and I'll answer properly <s>.  I hope not so much delay this time.



    Thursday, December 13, 2007 4:57 PM
  • Lisa,


    I will try to explain you my exact scenario.


    I have 2 Datatables.


    1st Datatable has just 1 row of data.

    2nd Datatable has some multiple rows.


    Now i am using Reportviewer to display above datatable in specific format.

    1) The values of 1st Datatable i am displaying in texboxes(Report Item) by using SetParameters method of LocalReport.

    2) while values of 2nd Datatable as there are multiple rows i want to use table(report Item).


    Now the 1st condition i am sucessful at Runtime but second condition gives a compile time error i have already mentioned in my previous post.


    So is there any way i can set my datatable with multiple rows to a Table(Report Item) in ReportViewer Dynamically(Runtime).

    If yes please provide me with some sample code.


    No Delay at all as i was involved in some other task.



    Friday, December 14, 2007 4:51 AM

    OK it really is a local report -- so you are passing this information to the *report* not to the *dataset*, because you have already created your dataset outside the report.


    So... in SetParameters, what have you tried to use for passing on the instructions for your columns?  There are many ways to do this and it is not clear from your response what you actually tried so I can't explain the compile time error and give you a correction <s>.


    There is sample code to do this in the other thread referred to in an earlier message in this one.  There are many other ways to do it, too, but it would be easier to illustrate in your exact case if I knew what the issues were.


    For example, do your different datasets always have the same number of columns?  Are you passing information about the column names + header labels, just the column names, or what?



    Friday, December 14, 2007 4:05 PM
  • one more thing: You said earlier:



    But when i want to pass an array of string as parameter to a table in .rdlc i am not able to figure out how to do that.

    Also when i try to do that a compile time error appears.



    So that is at least part of the issue... show us what you are doing to pass the array of string and what you are doing to try to interpret that array in the RDLC, and we can figure out what's wrong...



    Friday, December 14, 2007 4:07 PM
  • Hey Zuomin,


    your sample program was very helpfull.


    Can you please help me how to make the existing report with drilldown option along with summary report

    like I need summary values first then once drilldown need to show the details.

    This will be much help full for me.


    Thanks & Regards


    Thursday, July 15, 2010 6:58 AM
  • Yes.
    You can genereate rdlc dynamically.



    The sample program  was very helpfull for me but I am not able to group the fields

    ie. I need to display  summary data first .Once the drildown was expanded then only all record has to display.

    If you have any sample please send me.


    Thanks & Regards


    Thursday, July 15, 2010 8:33 AM
  • Take a look at This componet will generate the report for you.



    Friday, March 2, 2012 8:19 PM