views:

476

answers:

3

I'm generating the RDLC XML schema and showing the report in the ReportViewer control. No problems there.

Now, I want a report with 2 tables, with 2 differents dataset.
Something like this gets generated:

<Body>
    <ReportItems>
            <Table Name="Table1">
            ....
            </Table>
            <Table Name="Table2">
            ....
            </Table>           
    </ReportItems>
</Body>

But, when printed, both tables start from the top, printing one table over the other (not nice)

Is there a way to tell that Table2 should start after Table1?

Update: I've tried with List with a fake DataSource, but it does not work.

+1  A: 

The tables should render one after the other. There must be something more going on in your RDLC. You are generating the RDLC yourself? Have you tried creating a dummy report with the report designer, dropping two tables in it, and examining the RDLC it generates? Multiple tables in one report is extremely common.

Also try setting their Top elements:

        <Table Name="Table1">
            <Top>1in</Top>
        </Table>
        <Table Name="Table2">
            <Top>5in</Top>
        </Table> 
Matt Greer
I've already examined the RDLC generated by VS2008 and there are no differences. Using `Top` is not an option, since I don't know the Height of the preceding table.
Eduardo Molteni
Matt: do you have some report with two tables so I can examine?
Eduardo Molteni
A: 

OMG! It was as easy as adding ZIndex=2 to the second table.
Even ZIndex is not important, setting magic fake Top is all that matters.

<Body>
    <ReportItems>
            <Table Name="Table1">
                 <Top>1cm</Top> 
                 ....
            </Table>
            <Table Name="Table2">
                 <Top>2.25cm</Top> <!-- more than table1 Top + Height -->
                 ....
            </Table>           
    </ReportItems>
</Body>

Still not sure if order in the XML is important and setting different Tops
The order in the XML is not important, but the Top is. You must set a top greater that Table1 top+height (that height that it virtually have in the designer)

Eduardo Molteni
+1  A: 

I use a lot of report with multiple tables, I simply Add the the start of the second table exactly over the end of the second table, when rendered they appears one after the other. So you need to configure the first table with:

<Table Name="table1">
<DataSetName>DataSets_ChiamateGroup</DataSetName>
<KeepTogether>true</KeepTogether>
<Top>36cm</Top>
<Height>3.00001cm</Height>

And

<Table Name="table2">
<DataSetName>DataSets_ChiamateGroup</DataSetName>
<KeepTogether>true</KeepTogether>
<Top>39cm</Top>
<Height>5.00000cm</Height>

Note that Table1.Top+Table1.Height=Table2.Top

Here is an example of two tables layout (with additional charts on top)

report designer two tables

Hope it helps!!

contam
Thanks Contam, that is what I'm finding. Too bad you didn't answer before I've selected the correct answer (that can't be undone)
Eduardo Molteni
No problem... I hope that the solution will be useful also to other people!
contam