This is a windows desktop application. I am using List<>
as data
in rdlc.
Below is the code.
public class Balance_Party
{
public string Name { get; set; }
public double Amount { get; set; }
public static List<Balance_Party> GetPartyBalance()
{
List<Balance_Party> list = new List<Balance_Party>();
string qry = "SELECT " +
"[PRTY_NAME] AS NAME,[PRTY_AMOUNT] AS AMOUNT " +
"FROM [PARTY_MSTR]";
DataTable dt = globalData.q.select(qry, globalData.connectionstring);
list = (from DataRow row in dt.Rows
select new Balance_Party
{
Name = row["NAME"].ToString() == string.Empty ? " " : row["NAME"].ToString(),
Amount = row["AMOUNT"].ToString() == string.Empty ? 0 : Convert.ToDouble(row["AMOUNT"].ToString())
}).ToList();
return list;
}
}
In the Report_Viewer
form, I load this List<>
as per below.
Microsoft.Reporting.WinForms.ReportDataSource dataset1
= new Microsoft.Reporting.WinForms.ReportDataSource();
this.reportViewer.LocalReport.DataSources.Clear();
this.reportViewer.LocalReport.ReportEmbeddedResource = "Report";
var list1 = Balance_Party.GetPartyBalance();
dataset1 = new Microsoft.Reporting.WinForms.ReportDataSource("Balance_Party", list1);
dataset1.Value = list1;
this.reportViewer.LocalReport.DataSources.Add(dataset1);
this.reportViewer.LocalReport.Refresh();
this.reportViewer.RefreshReport();
I added ReportData
after adding Tablix
in the RDLC
, To add report data - Add DataSet -> Choose datasource -> chose the Class Balance_Party -> load it to tablix
.
Now a problem is raised with one of the reports that it requires to add columns run time in the tablix
that already has dataset to display. How to do it? How to add columns run time in any tablix.?
EDIT:- The purpose to add column is, suppose the report is about the total sales per party. Now what if a party does business for another type of item.
E.g. First column is Party and second is Total sales for one item say Pencils. Now some parties start selling of Ball Point pens. So in designer I have added only one column. Now I need extra column for Ball Point pens. On my computer I can redisgn the report, but on client's pc it's not possible.