Click here to Skip to main content
13,046,087 members (57,888 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 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
Please Sign up or sign in to vote.

Solution 1

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

Hope this helpful.

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
I've solved that error by the solution of this link "".

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
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
Please Sign up or sign in to vote.

Solution 2

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

Solution 4


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


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
Web01 | 2.8.170713.1 | Last Updated 25 Sep 2013
Copyright © CodeProject, 1999-2017
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