Click here to Skip to main content
14,980,370 members
Articles / Web Development / ASP.NET
Posted 19 Dec 2006


35 bookmarked

Localization (Globalization) of RDLC reports in ASP.NET applications

Rate me:
Please Sign up or sign in to vote.
4.52/5 (14 votes)
12 Sep 2008CPOL2 min read
Localization of the RDLC reports in the ASP.NET applications


If you need to display an RDLC report in one of several different languages, you need to create a localized version of the report for each language because RDLC reports do not support localization at the moment. However, that is complex and time-consuming, so it would be useful to localize the RDC reports similar to the way .NET handles localization normally.


The reports that you create for ReportViewer controls (.RDLC files) are XML files containing the definition of the report, so the procedure of localization doesn't look too difficult:

  1. Load the RDLC file using the Load method of the XMLDocument class.
  2. Go through the nodes of the XML document and localize the value of the Value property of the static elements of the report.
  3. Load the updated RDLC document into the LocalReport object using the LoadReportDefinition method.

To specify a resource key used for localization of the text of static elements, we can use a property named ValueLocID - the localization identifier associated with the Value property. I have not found any information about this property in any of the MSDN documentations or the RDL specification, and looks that this property is not used by the ReportViewer control in any way, so I hope that it is safe enough to use this property to specify a resource key for the localized text. Similarly, we can use the ToolTipLocID and LabelLocID properties for the localization of the ToolTip and Label properties.


private void LocalizeReport(LocalReport report)
    // Load RDLC file. 
    XmlDocument doc = new XmlDocument();
    catch (XmlException)
        // TIP: If your web site was published with the updatable option switched off
        // you must copy your reports to the target location manually
    // Create an XmlNamespaceManager to resolve the default namespace.
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
    nsmgr.AddNamespace("nm", "" + 
    nsmgr.AddNamespace("rd", "" + 
    //path to the local resource object
    string resourcePath = Path.Combine(ResolveUrl("."), 
    //Go through the nodes of XML document and localize
    //the text of nodes Value, ToolTip, Label. 
    foreach (string nodeName in new String[] { "Value", 
             "ToolTip", "Label" })
        foreach (XmlNode node in doc.DocumentElement.SelectNodes(
                 String.Format("//nm:{0}[@rd:LocID]", nodeName), nsmgr))
            String nodeValue = node.InnerText;
            if (String.IsNullOrEmpty(nodeValue) || !nodeValue.StartsWith("="))
                    String localizedValue = (string)HttpContext.GetLocalResourceObject(
                      resourcePath, node.Attributes["rd:LocID"].Value);
                    if (!String.IsNullOrEmpty(localizedValue))
                        node.InnerText = localizedValue;
                catch (InvalidCastException)
                    // if the specified resource is not a String
    report.ReportPath = String.Empty;
    //Load the updated RDLC document into LocalReport object.
    using (StringReader rdlcOutputStream = new StringReader(doc.DocumentElement.OuterXml))
        // TIP: If the loaded report definition contains any
        // subreports, you must call LoadSubreportDefinition

An example of using of LocalizeReport function is shown below:

protected void Page_Load(object sender, EventArgs e)
    ReportViewer reportViewer = new ReportViewer();
    reportViewer.LocalReport.ReportPath = "App_Data/Reports/Report.rdlc";
    // you must run the LocalizeReport function before
    // setting parameters or data sources to the report
    // set parameters
    // set datasources

Step-by-Step Instructions


  1. Create the App_LocalResources folder.
  2. Create a resx file named after your report for each language you want to support (e.g., for a report file named Report.rdlc, you would create a Report.rdlc.resx for the default language, and for Spanish). Always have a default language resx file.
  3. Add whatever strings you need to the resx file.
  4. In your RDLC, enter the string names from the resx file as the value of the property of ValueLocID (e.g., for the resource string Hello, set the value of property ValueLocID of textboxHello to Hello).
  5. Call the LocalizeReport function. Note that you must run the LocalizeReport function before setting parameters or data sources to the report; otherwise, it will not work.


This article is partly based on the example created by Joe Jone.


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


About the Author

Alexander Vologin
United States United States
No Biography provided

Comments and Discussions

QuestionParameters translation Pin
Member 1298758514-Feb-17 6:33
MemberMember 1298758514-Feb-17 6:33 
Question[My vote of 2] This approach does not work for charts Pin
koriandr13-Mar-13 13:38
Memberkoriandr13-Mar-13 13:38 
QuestionExport problem with localization Pin
TSGLB22-Mar-12 10:43
MemberTSGLB22-Mar-12 10:43 
AnswerRe: Export problem with localization Pin
TSGLB28-Mar-12 11:26
MemberTSGLB28-Mar-12 11:26 
GeneralMy vote of 4 Pin
samiatcodeproject22-Nov-11 4:44
Membersamiatcodeproject22-Nov-11 4:44 
GeneralExport to PDF Pin
sgamage0625-Apr-11 20:13
Membersgamage0625-Apr-11 20:13 
GeneralRe: Export to PDF Pin
Alexander Vologin3-May-11 5:47
MemberAlexander Vologin3-May-11 5:47 
GeneralRe: Export to PDF Pin
sgamage065-May-11 20:54
Membersgamage065-May-11 20:54 
GeneralError in RDLC report creating! Pin
someonesays4-Aug-10 0:19
Membersomeonesays4-Aug-10 0:19 
GeneralChart Control Pin
Rodrigo Brandao16-Nov-09 2:18
MemberRodrigo Brandao16-Nov-09 2:18 
GeneralThank you Pin
Member 201849730-Oct-09 12:27
MemberMember 201849730-Oct-09 12:27 
GeneralBest Localization Plug-in for Visual Studio. Pin
Alexander Nesterenko17-Dec-08 21:36
MemberAlexander Nesterenko17-Dec-08 21:36 
GeneralSubReport problem Pin
galodoido15-Sep-08 5:06
Membergalodoido15-Sep-08 5:06 
AnswerRe: SubReport problem Pin
czeshirecat27-May-09 8:24
Memberczeshirecat27-May-09 8:24 
GeneralRe: SubReport problem Pin
andrea_scurci22-Mar-10 0:47
Memberandrea_scurci22-Mar-10 0:47 
GeneralPrecompiled web Pin
Member 411834010-Sep-08 23:21
MemberMember 411834010-Sep-08 23:21 
GeneralRe: Precompiled web Pin
Alexander Vologin11-Sep-08 10:03
MemberAlexander Vologin11-Sep-08 10:03 
GeneralRe: Precompiled web Pin
Member 411834011-Sep-08 10:34
MemberMember 411834011-Sep-08 10:34 
GeneralRe: Precompiled web Pin
Alexander Vologin12-Sep-08 7:00
MemberAlexander Vologin12-Sep-08 7:00 
GeneralRe: Precompiled web Pin
Member 411834015-Sep-08 4:26
MemberMember 411834015-Sep-08 4:26 
GeneralRe: Precompiled web Pin
Alexander Vologin22-Sep-08 8:08
MemberAlexander Vologin22-Sep-08 8:08 
GeneralExecution problem : System.InvalidOperationException Pin
chabouni8-Sep-08 3:37
Memberchabouni8-Sep-08 3:37 
GeneralRe: Execution problem : System.InvalidOperationException Pin
Alexander Vologin11-Sep-08 10:01
MemberAlexander Vologin11-Sep-08 10:01 
GeneralRe: Execution problem : System.InvalidOperationException Pin
Alexander Vologin12-Sep-08 7:00
MemberAlexander Vologin12-Sep-08 7:00 
GeneralExcellent work, I've used it on a win app project Pin
andycted3-May-08 1:07
Memberandycted3-May-08 1:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.