Click here to Skip to main content
12,500,761 members (47,235 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# RDLC Reporting
Hi everyone,

I want to create a rdlc report with dynamic columns.I mean i want to add or remove columns and also the sort of the columns at runtime in my report.by the way my data is in a datatable.
I have used xmlDocument to load my rdlc file and modify it but an error occured that says something like this : "the data at the root level is invalid".

please tell me how can i do that?
Posted 24-Jan-12 21:56pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi phoenix1167,
I think you've missed something, check out this below link.

http://dobrzanski.net/2009/02/06/how-to-dynamically-add-new-columns-to-report-created-with-reporting-services/[^]

Hope this helpful.

Regards,
Bluesathish
  Permalink  
Comments
phoenix1167 27-Jan-12 23:58pm
   
Hi bluesathish,
Thanks. I've tried the solution of this link too already.but it does not work and i've received that error again.I opened my rdlc report with Notepad but i did not see any Table tag in /Report/Body/ReportItems path...
please guide me.I am too new in using xml files...
phoenix1167 28-Jan-12 4:30am
   
Hi,
I've solved that error by the solution of this link "http://stackoverflow.com/questions/310669/why-does-c-sharp-xmldocument-loadxmlstring-fail-when-an-xml-header-is-included".

but now i have another problem!
I have modified my rdlc file in my application but i could not save changes.I've used xmlDocument.Save() method but anything happens...
what is my mistake???
wsc0918 25-Oct-12 21:19pm
   
Hi,
I provide my solution when I want to re-save XmlDocument as follow:
System.IO.File.WriteAllText(@"C:\new.rdlc", XmlDocument.InnerXml);
Hope this us useful for you.
phoenix1167 28-Jan-12 23:33pm
   
I am waiting for your response please...
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Eyval, I have found my response in this link[^]
  Permalink  
Comments
bluesathish 7-Feb-12 0:01am
   
good, all the best.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Here I found good example of loading RDLC in runtime, we may also hide columns from codebehind

http://www.mixedresponse.com/Blog/Details/10
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Hi

I had the same situation as like you. So what exactly i have done is:

Create a static RDLC with 25 columns(u may extend).

Hide all the columns by default.

Load the RDLC as XML.

Now collected my run time table columns and replaced the static columns of the RDLC with orginal table columns
example
COl1,COl2,Col3,......Col 25
after getting xml
Col1 should replaced with FirstName, then set as visible
Col2 should replace with LastName, then set as visible
Col3 should replace with Adddresss, then set as visible
like this make the changes for columns.
Similary make a loop for the data of orginal table put the data in the newly created columns,
Now your RDLC will be ready with new columns and fresh data

Now show this report to end user.

One important event you need to implement is RDLC_Unload() in which you need to Reset all your changes ie set Col1,Col2....Col25 remove data etc)

Now check this with the following link
http://lbrtdotnet.wordpress.com/2011/08/12/reporting-services-creating-a-dynamic-column-tablix-report-using-rdl-generator

Thanks
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 25 Sep 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100