locked
Display table data with Reportviewer as columns instead of rows RRS feed

  • Question

  • User-1698143701 posted

    Hello all,

    I am working on a database using SQL Server 2012 and C# on Visual Studio.NET 2010.

    I am using Reportviewer to create various reports with no problems so far. I have a specific problem that has been puzzling me for some time and I can't find a satisfactory solution. 

    I have a table which represents a box of sample tubes that contains 100 tubes which are aranged in a 10x10 gridlike this:

    My table has the following fields:

    Position|Horizontal|Vertical|Value

    Example Data Rows:

    1|1|1|Sample1

    2|1|2|Sample2

    3|1|3|Sample3

    and so on until

    100|10|10|Sample100

    Now I want to be able to print the contents of this table similar to the grid figure, in a 10x10 grid. Something like this

    1 SAmple 1   |2 Sample 2 |3 Sample 3     |4...|10 Sample 10|

    11 Sample 11| 12 Empty   |13 Sample 13 |...|

    21 Sample 21|...|

    ...

    How can I display data rows from my table in Rportviewer in one row and after 10 columns go to the next line to print the next 10 etc, in order to create a grid that looks like the real box of samples?

    I tried creating a data list and a multicolumn Report after following this tutorial:"Creating Mailing Labels in SQL Server Reporting Services" but the data gets printed sequentially all in the first column, then goes to the second column to continue from where its left off and the grid is somehow inverted from what i want it to look like.  

    Has anyone tried to prinf a report using a grid and print data in rows instead of columns?

    I appreciate any input you might have. 

    Friday, June 21, 2013 6:01 AM

Answers

  • User-1225287840 posted

    You could use DataList control with RepeatColumns=10 to show 10 X n rows grid format.

    <asp:DataList ID="DataList1" RepeatDirection="Horizontal" BorderStyle="solid" BorderWidth="2" RepeatLayout="Table" RepeatColumns="10" runat="server">

    <asp:Literal ID="Literal1" Text='<%# Container.DataItem("position") + " " + Container.DataItem("value") %>' runat="server" />

     </asp:DataList> 

    .RS.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 25, 2013 9:55 AM

All replies

  • User-67082742 posted

    Hi,

    For this you might need to add some kind of counters to your dataset like RowNumver, Column Number and Pagenumber. You can do that by some sql calculations. Once you have that , you can folloow these steps :

    1.Add a table with one column only and row group on "Sample".

    2.Now add another table with 1 row and 1 column only. Delete the default group. Add a parent column group on it for your ColumnNumber/RowNumber parameter.

    3. Now cut and paste the previous table in this table. This should help in getting desired result.

    Thanks!

    AB

    Friday, June 21, 2013 8:26 AM
  • User1080904399 posted

    This seems like it could be done by simply creating a row group on your horizontal field and a column group on your vertical field and using your value field for your detailed data.

    Friday, June 21, 2013 4:40 PM
  • User-1698143701 posted

    Can you elaborate please? Row group will be applied on a specific value of the table? WIll I be able to go to the next row after 10 values with the rowgroup? Thank you for your answers. 

    Tuesday, June 25, 2013 2:03 AM
  • User-1225287840 posted

    You could use DataList control with RepeatColumns=10 to show 10 X n rows grid format.

    <asp:DataList ID="DataList1" RepeatDirection="Horizontal" BorderStyle="solid" BorderWidth="2" RepeatLayout="Table" RepeatColumns="10" runat="server">

    <asp:Literal ID="Literal1" Text='<%# Container.DataItem("position") + " " + Container.DataItem("value") %>' runat="server" />

     </asp:DataList> 

    .RS.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 25, 2013 9:55 AM