[ReportViewer]Background Thread Uses Wrong Culture!

Hi all,

Using VS 2005 and the reportviewer with local objects as datasources, I have run into a problem when the report is generated.

It seems that the reportgeneration is using a background thread (of course, the user can abort it), BUT this thread is (always) using "en-US" as culture! My application is using sv-FI, so what on earth is hapening

This leads to at least two problems:

1. DateTime.ToShortDateString() returns a datetime using "M/d/yyyy" instead of "d.M.yyyy".

2. The PaperSize is set to "letter" instead of A4.

You guys think its fun when the printer is flashing like a christmas tree, when a letter-sized paper has been printed to a printer using A4




Answer this question

[ReportViewer]Background Thread Uses Wrong Culture!

  • zhongzhong

    Yes that was the problem. But how do I specify the languge/culture dynamically I do not want to bind the language statically on the report, rather to some languge property on my datasource!

    But there is still a problem:

    When I try to print a report, nothing happens the first time i click print. I think the job is sent to the printer, at least it is not in my local printer queue, but the printer never receives the job! If I then print another time, the job is sent and received and printed normally. The first time the reportviewer sends two pages to the printer (according to the small dialog flashing after you click print), but the report is only on one page! The second time the reportviewer only sends one page and one page only. If I programmatically set the layout to "PrintLayout", instead of the default "NormalLayout", this problem does not happen. What's up with this

  • DFMartinJr

    You can effectively set the report language to the thread culture by setting it to the expression "=User!Language".

    We have received some bug reports similar to the printing problem you describe and are currently investigating them. But I don't have an answer on it yet.


  • slolife

    Thank you for your reply.

    But can I set the language at runtime Wouldn't it be a common situation to print a report using another culture (i.e. not the culture of the user) For exampel if a user in EU wants to print a report for a customer in US.

    How can I solve this

  • James Randle

    The background thread does run in the same culture as the primary thread. But if you report is set to a specific culture, that culture will be used. What is the Language property set to on your report

    As far as the A4 problem, you might be running into a known bug. Take a look at this thread for workarounds: http://forums.microsoft.com/MSDN/ShowPost.aspx PageIndex=1&SiteID=1&PostID=126378


  • Sean Hederman

    You can do this.  Since the language can be an expression, it can also be based on report parameters.  Try this RDL, which has two parameters - a date to display and the culture to display it in.

    < xml version="1.0" encoding="utf-8" >
    <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
      <BottomMargin>1in</BottomMargin>
      <RightMargin>1in</RightMargin>
      <ReportParameters>
        <ReportParameter Name="TheDate">
          <DataType>DateTime</DataType>
          <DefaultValue>
            <Values>
              <Value>=Now()</Value>
            </Values>
          </DefaultValue>
          <AllowBlank>true</AllowBlank>
          <Prompt>Select a date</Prompt>
        </ReportParameter>
        <ReportParameter Name="MyCultureParameter">
          <DataType>String</DataType>
          <AllowBlank>true</AllowBlank>
          <Prompt>Select a culture</Prompt>
          <ValidValues>
            <ParameterValues>
              <ParameterValue>
                <Value>fr-FR</Value>
                <Label>French</Label>
              </ParameterValue>
              <ParameterValue>
                <Value>en-US</Value>
                <Label>English</Label>
              </ParameterValue>
            </ParameterValues>
          </ValidValues>
        </ReportParameter>
      </ReportParameters>
      <rd:DrawGrid>true</rd:DrawGrid>
      <InteractiveWidth>8.5in</InteractiveWidth>
      <rd:SnapToGrid>true</rd:SnapToGrid>
      <Body>
        <ReportItems>
          <Textbox Name="textbox1">
            <Left>0.375in</Left>
            <Top>0.375in</Top>
            <rd:DefaultName>textbox1</rd:DefaultName>
            <Width>3.25in</Width>
            <Style>
              <PaddingLeft>2pt</PaddingLeft>
              <PaddingBottom>2pt</PaddingBottom>
              <PaddingRight>2pt</PaddingRight>
              <PaddingTop>2pt</PaddingTop>
              <Language>=Parameters!MyCultureParameter.Value</Language>
            </Style>
            <CanGrow>true</CanGrow>
            <Height>0.25in</Height>
            <Value>=Parameters!TheDate.Value</Value>
          </Textbox>
        </ReportItems>
        <Height>2in</Height>
      </Body>
      <rd:ReportID>44768779-563d-4112-9a06-a760a44f9e91</rd:ReportID>
      <LeftMargin>1in</LeftMargin>
      <Width>6.5in</Width>
      <InteractiveHeight>11in</InteractiveHeight>
      <Language>=Parameters!MyCultureParameter.Value</Language>
      <TopMargin>1in</TopMargin>
    </Report>


  • [ReportViewer]Background Thread Uses Wrong Culture!