John Nguyen
John Nguyen

Reputation: 701

How to show the table horizontally in (rdlc) report

I want to show the table horizontally like this:

| data1 | data2 | data3 | data4 | ....

| data5 | data6 | ....

For more information, I am using visual studio 2010. and it will go to new line

I saw similar question here but it goes to new page instead of new line

Thanks for advance

Upvotes: 4

Views: 3459

Answers (2)

Mehdi Haghshenas
Mehdi Haghshenas

Reputation: 2447

you must crate data table for this

for example for 3 column you Crate DataTable for this purpose

DataTable dt=new DataTable();
dt.Columns.Add("Data1");
dt.Columns.Add("Data2");
dt.Columns.Add("Data3");
DataRow drow=dt.NewRow();
for(int i=1;i<olddt.Rows.Count;i++)
{
  if(i%3==0 && i!=0)
  {
     dt.Rows.Add(drow); 
     drow=dt.NewRow();
  }
  if(i%3==0)
  {
    drow[0]=olddt[i][Column].ToString();
  }
  if(i%3==1)
  {
     drow[1]=olddt[i][Column].ToString();
  }
  if(i%3==2)
  {
    drow[2]=olddt[i][Column].ToString();
  }
}

in this example oldDt is your old data

Upvotes: 2

Mehdi Haghshenas
Mehdi Haghshenas

Reputation: 2447

in the rdl file or rdlc file in reportproperties set Columns to number of horizontal column you want to show enter image description here

for example you want to show 3 column show data and then go to next row

column1 | column2  | column3
column4 | column6  | column6

in report properties you set columns 3 and set report size width, size of column1 data automatically show in 3 column now you can use this report as sub report in other report

Upvotes: 2

Related Questions