2
votes

I use Report Viewer in visual studio 2010. I have 2 problems: 1. I can't center the table , it's align automatically to left. 2. I want to align the data into the table to right. how can I do that?

Thank you. (this is my code for Report Viewer:)

Example

 <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div >
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
            Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
            WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"  Height="800px" Width="100%" RightToLeft="YES">
            <LocalReport ReportPath="Report3.rdlc" > 
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            SelectMethod="GetData" 
            TypeName="Shemen.ta2014DataSetTableAdapters.SoftwareTableAdapter">
        </asp:ObjectDataSource>
    </div>
2

2 Answers

2
votes

In order to center the report itself, try:

<center>
 <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
                   WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"  Height="800px" Width="100%" RightToLeft="YES">
  <LocalReport ReportPath="Report3.rdlc">
     <DataSources>
        <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
     </DataSources>
  </LocalReport>
 </rsweb:ReportViewer>
</center>

As for aligning the data, you would have to do that at the report level by selecting the column and setting the Horizontal Align property.

I hope this helps.

0
votes

Just came across this issue and found out it can will solve by a few line of javascript. Enjoy

<script type="text/javascript">

 window.onload = function() {

        $('td#oReportCell', window.parent.frames[0].frames[1].document).next().remove();
        $('div#oReportDiv table', window.parent.frames[0].frames[1].document).attr("align", "center");
};

</script>