Results 1 to 2 of 2

Thread: hiding columns in a report viewer

  1. #1
    keroed1 Guest

    Default hiding columns in a report viewer

    i am building a report.rdlc and using the report viewer and i wanted to know how can i hide or unhide columns in my report is this possible? can anyone assist me?

    oh p.s. using c# but it doesn't matter if u know how to do it in vb will jus convert it
    Last edited by keroed1; Jul 2, 2007 at 11:55 AM.

  2. #2
    keroed1 Guest

    Default

    whats up guys a found a way to fix my problem was fooling around and an idea came to me and tested and whalla it worked so here is what i did

    step 1
    create a dataset with a table that has all the possible columns that you might use in your report

    step 2
    add all of these columns to your report

    step 3
    create report parameters for all the columns u want to hide / un-hide

    step 4
    assign the value of the hidden property for each column to evaluate whether or not to set hidden property to true or false

    example set hidden property to
    Code:
    =iif(Parameters!param_TicketId.Value="T",True,False)
    step 5
    assign values to the report parameters wherever you are going to build and run the report

    Code:
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc");
            ReportDataSource rds = new ReportDataSource();
            rds.Name = "spTroubleTicket_AllTableAdapter";
            rds.Value = dsReport.Tables[0];
            ReportViewer1.LocalReport.DataSources.Add(rds);
    
            ReportParameter[] param = new ReportParameter[2];
            
            param[0] = new ReportParameter("param_TicketId", "F");
            param[1] = new ReportParameter("param_TimeRecieved", "T");
            
            ReportViewer1.LocalReport.SetParameters(param);
            ReportViewer1.LocalReport.Refresh();
    you can do any manipulation you want based on the code above my original code i allowed my users to select the column the wanted to be in the report. and i also allowed them to generate the dataset based on the specific search criteria they chose to use and use this as the dataset.

    so in essence i create a data table with all possible columns and added it to my report and then allowed user to hide and unhide columns and generate there dataset to be used on the report dynamically

    -EDIT- any questions be free to ask

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •