locked
How to bind Report Viewer inside loop for all values in code behind page? RRS feed

  • Question

  • User946142141 posted

    I have 10 users,passing all the users inside foreach loop and binding the report viewer. but Report viewer binds only for last user alone.How I can bind for all users and maintain Reportviewer datasource to retain data after each user????

     foreach (DataRow row in dsuser.Tables[0].Rows)
                {
                

                    hdnuserid.Value = row["id"].ToString();

                     sqlDataAccess sda = new sqlDataAccess();
                     object[] obj = { hdnstoreId.Value, hdnfromdate.Value, hdntodate.Value, hdnuserid.Value };
                     DataSet ds = sda.executeSqlReturnDataSet("Get_Report_ClosedDrawerReport", CommandType.StoredProcedure, obj);
                   
                     ReportDataSource datasource  = new ReportDataSource("ds_ClosedDrawerReport", ds.Tables[0]);
                      
                     ReportViewer1.LocalReport.DataSources.Add(datasource);

    }

    Wednesday, October 3, 2012 10:08 AM

Answers

  • User-1028151323 posted

    you should create the dataset outside your loop, load it IN the loop and attach it to the report AFTER the loop executes.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 3, 2012 1:31 PM