none
How to display parameter value in text box in reportviewer RRS feed

  • Question

  • Hello,
    I have a query which brings up data for a selected date, however when the data is displayed it does not display the change of date is the report header, it brings up the value entered in .RDLC when building the report. I am using Reporting Services to build a report and using local processing using ReportViewer control in Visual Studio 2008 using c#
    Any help will be appreciated.
    Regards
    Franklin

    Monday, August 10, 2009 11:18 AM

Answers

  • Thanks so much for your help on this so far. I added the following code to my .cs file and it worked.

    protected

     

    void ReportButton_Click(object sender, EventArgs e)

    {

     

    ReportParameter[] parameters;

    parameters =

    new ReportParameter[2];

    parameters[0] =

    new ReportParameter("START_DATE", txtStartDate.Text);

    parameters[1] =

    new ReportParameter("END_DATE", txtEndDate.Text);

    ReportViewer1.LocalReport.SetParameters(parameters);

     

    ReportDataSource rds = new ReportDataSource("ObjectDataSource1");

    ReportViewer1.LocalReport.Refresh();

    ReportViewer1.Visible =

    true;

     

    }

    Cheers
    Franklin

    Friday, August 14, 2009 11:39 AM

All replies

  • Hello,
    I have a query which brings up data for a selected date, however when the data is displayed it does not display the change of date is the report header, it brings up the value entered in .RDLC when building the report. I am using Reporting Services to build a report and using local processing using ReportViewer control in Visual Studio 2008 using c#
    Any help will be appreciated.
    Regards
    Franklin


    I also would like to add the following to the query to quicken the resolution if possible.

    What I am trying to do is something like this.

    I have 2 parameters, start_date and End_date, i am using a ajax calendar control called txtStartDate and txtEndDate to collect values from users at runtime.
    After I do that and click on View Report I would like to display the value the users are selecting as dates in the .rdlc where there is already a textbox which i coded while creating the .RDL in SSRS. Let me know if this would work.
    I can add 2 text boxes in the asp page and display the values but these values will not be displayed in the excel download of the report.
    Hope this makes sense.

    Regards
    Franklin
    Tuesday, August 11, 2009 2:30 PM
  • Franklin,

    I am doing something like you describe, maybe this works for you:

                DateTime fechaIni = Convert.ToDateTime(dtpFechaIni.Text); // INITIAL DATE
                DateTime fechaFin = Convert.ToDateTime(dtpFechaFinal.Text); // END DATE

                // Reporte de Entradas
                if (rbuEntradas.Checked)
                {
                    try
                    {
                        this.tPrinterTableAdapter.FillByEntradas(this.KardexPrinterDBDataSet.tProductos, fechaIni, fechaFin);
                        this.repViewer.LocalReport.ReportEmbeddedResource = "SACK.repEntradas.rdlc";
                        this.repViewer.RefreshReport();
                    }
                    catch (System.Exception ex)
                    {
                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                }
                // Reporte de Salidas
                if (rbuSalidas.Checked)
                {
                    try
                    {
                        this.tPrinterTableAdapter.FillBySalidas(this.KardexPrinterDBDataSet.tProductos, fechaIni, fechaFin);
                        this.repViewer.LocalReport.ReportEmbeddedResource = "SACK.repSalidas.rdlc";
                        this.repViewer.RefreshReport();
                    }
                    catch (System.Exception ex)
                    {
                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                }

    You have to edit your query inside the dataset to something like this:

    SELECT     tProductos.ProductoID, tProductos.Nombre, tProductos.Status, tExistencia.ExistActual, tMovimientos.NumDocto, tMovimientos.Fecha,
                          tMovimientos.Entrada, tMovimientos.Salida, tMovimientos.TipoMov, tMovimientos.CostoUnitario, tMovimientos.CostoTotal,
                          tMovimientos.UnidadMedida, tMovimientos.Lugar
    FROM         tProductos INNER JOIN
                          tExistencia ON tProductos.ProductoID = tExistencia.ProductoID INNER JOIN
                          tMovimientos ON tProductos.ProductoID = tMovimientos.ProductoID
    WHERE     (tMovimientos.Fecha >= @fechaIni) AND (tMovimientos.Fecha <= @fechaFin)


    Think left and think right and think low and think high. Oh, the things you can think up if only you try!
    Wednesday, August 12, 2009 12:30 AM
  • Hello,
    I checked this and found that I am not able to compile my code. rbuEntradas.Checked - is that a control on your reportviewer ?
    What i did is the following
                    DateTime START_DATE = Convert.ToDateTime(txtStartDate.Text);
                    DateTime END_DATE = Convert.ToDateTime(txtEndDate.Text);
    START_DATE - @START_DATE in my query string &
    END_DATE - @END_DATE in my query string,
    now how would i associate this to a text box i created in the (RDL) and not RDLC...
    Hope this helps.
    Regards
    Franklin
    Wednesday, August 12, 2009 4:42 PM
  • Hello,
    I checked this and found that I am not able to compile my code. rbuEntradas.Checked - is that a control on your reportviewer ?
    THIS IS JUST A RADIO BUTTON, WHEN THE USER CHECK ON IT TAKE THE REPORT FOR "ENTRADAS"

    What i did is the following
                    DateTime START_DATE = Convert.ToDateTime(txtStartDate.Text);
                    DateTime END_DATE = Convert.ToDateTime(txtEndDate.Text);
    START_DATE - @START_DATE in my query string &
    END_DATE - @END_DATE in my query string,

    now how would i associate this to a text box i created in the (RDL) and not RDLC...
    Hope this helps.
    Regards
    Franklin

                    DateTime START_DATE = Convert.ToDateTime(txtStartDate.Text); // THIS IS YOUR TEXTBOX 1 FOR START DATE
                    DateTime END_DATE = Convert.ToDateTime(txtEndDate.Text); // THIS IS YOUR TEXTBOX 2 FOR END DATE

                    //HERE YOU PASS THE 2 DATES AS PARAMETERS
                        this.TableAdapter.FillByYOURQUERY(this._DataBaseDataSet._table, START_DATE, END_DATE);

                        this.repViewer.RefreshReport();


    Think left and think right and think low and think high. Oh, the things you can think up if only you try!
    Wednesday, August 12, 2009 4:55 PM
  • Hi There,

    this.TableAdapter.FillByYOURQUERY(this._DataBaseDataSet._table, START_DATE, END_DATE);

    FillByYOURQUERY - do you mean the table adapter name?

    I am new to ASP.NET and hope you dont mind it.

    Probably I did not include some refrences in the include section.

    Regards
    Franklin
    Thursday, August 13, 2009 2:53 PM
  • FillByYOURQUERY - do you mean the table adapter name?

    No, I Mean the way you want to fill the report,
    Go to the DataSet Designer and you can create the queries
    for each table you have in there.


    this.TableAdapter.         FillByYOURQUERY      (this._DataBaseDataSet._table, START_DATE, END_DATE);
           TABLEADAPTER     QUERY                               DataBase            table   parameter 1   parameter 2

    QUERY :
    SELECT     tProductos.ProductoID, tProductos.Nombre, tProductos.Status, tExistencia.ExistActual, tMovimientos.NumDocto, tMovimientos.Fecha,
                          tMovimientos.Entrada, tMovimientos.Salida, tMovimientos.TipoMov, tMovimientos.CostoUnitario, tMovimientos.CostoTotal,
                          tMovimientos.UnidadMedida, tMovimientos.Lugar
    FROM         tProductos INNER JOIN
                          tExistencia ON tProductos.ProductoID = tExistencia.ProductoID INNER JOIN
                          tMovimientos ON tProductos.ProductoID = tMovimientos.ProductoID
    WHERE     (tMovimientos.Fecha >= @fechaIni) AND (tMovimientos.Fecha <= @fechaFin)

                                                          parameter 1                                                 parameter 2


    Think left and think right and think low and think high. Oh, the things you can think up if only you try!
    Thursday, August 13, 2009 3:04 PM
  • Thanks so much for your help on this so far. I added the following code to my .cs file and it worked.

    protected

     

    void ReportButton_Click(object sender, EventArgs e)

    {

     

    ReportParameter[] parameters;

    parameters =

    new ReportParameter[2];

    parameters[0] =

    new ReportParameter("START_DATE", txtStartDate.Text);

    parameters[1] =

    new ReportParameter("END_DATE", txtEndDate.Text);

    ReportViewer1.LocalReport.SetParameters(parameters);

     

    ReportDataSource rds = new ReportDataSource("ObjectDataSource1");

    ReportViewer1.LocalReport.Refresh();

    ReportViewer1.Visible =

    true;

     

    }

    Cheers
    Franklin

    Friday, August 14, 2009 11:39 AM