0

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.

DhavalR
  • 1,409
  • 3
  • 29
  • 57
  • Maybe if you shared the reason for adding columns at run time, it would help to provide a solution. – InitK Apr 24 '15 at 12:14
  • So, the issue is not that the number of columns is truly variable, but that you cannot deploy new version of the report with optionally visible column? – InitK Apr 24 '15 at 15:10
  • Yes the number of columns is variable. – DhavalR Apr 24 '15 at 15:12
  • If it is truly variable, then you may need to manipulate rdlc report (xml) at runtime, it was discussed few times: http://stackoverflow.com/search?q=change+rdlc+at+runtime – InitK Apr 24 '15 at 15:37

0 Answers0